Search code examples
iis-7url-rewritingiis-7.5isapi-rewriteurlrewriter.net

IIS7 Rewrite Module - Redirct from root to default.aspx


I have a situation where I need to rewrite from the root to default.aspx. So if someone hits www.domain.com or www.domain.com/ I need to redirect to www.domain.com/default.aspx - any idea what the regex for this looks like and which server variable to regex on?

When I run a trace and I visit www.domain.com/ or www.domain.com it always shows the SCRIPT_NAME and other similar server variables to have a value of /default.aspx - however this does not work in the rewrite module. E.g. when someone visits www.domain.com/ or www.domain.com the SCRIPT_NAME is still /default.aspx - so it doesn't seem to pick up that they visited the non default.aspx page.


Solution

  • I solved this by using a Url Rewrite map (part of the rewrite module), I was able to redirect from / to /default.aspx. As a rule before the rewrite map I make sure that all requests are redirected to an ending slash.