Using IIS URL Rewrite to redirect from the homepage

iis-7rewrite

This feels like it should be really really simple, but I can't figure it out. I must be missing something very obvious.

I want to redirect from the homepage of my site www.example.com to www.example.com/coming-soon

but I can't figure out what pattern to use to match this. I've tried:

  • keeping the pattern blank
  • /
  • ~

But none of these seem to match. I'm also not sure whether to match using reg ex, wildcards or exact match.

Best Answer

Use regex and for the URL field (top one) use '^($|default.aspx$)' (without the quotes). That means exactly nothing or exactly default.aspx. Obviously you can replace default.aspx with your own default doc. Whether or not someone enters a trailing slash won't matter. The URL field strips that.

You can use {HTTP_HOST} in the condition to filter by just your domain name.

And, if you use a rewrite rather than a redirect then the URL will remain at www.example.com and look a bit better to the user ... unless you want them to see the coming-soon in the URL.