IIS7 URL Redirection from root to sub directory [closed]
I am using Windows Server 2008 with IIS7. I need to redirect the users who come to www.mysite.com
to wwww.mysite.com/menu_1/MainScreen.aspx
. Here is the file structure I have for the projects:
-Sites
-Default Web Site
-Menu_1
-MenuService
-VscWebService
I will really appreciate any help on this.
Solution 1:
Here it is. Add this code to your web.config file:
<system.webServer>
<rewrite>
<rules>
<rule name="Root Hit Redirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/menu_1/MainScreen.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
It will do 301 Permanent Redirect (URL will be changed in browser). If you want to have such "redirect" to be invisible (rewrite, internal redirect), then use this rule (the only difference is that "Redirect" has been replaced by "Rewrite"):
<system.webServer>
<rewrite>
<rules>
<rule name="Root Hit Redirect" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/menu_1/MainScreen.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
Solution 2:
I think, this could be done without IIS URL Rewrite module. <httpRedirect>
supports wildcards, so you can configure it this way:
<system.webServer>
<httpRedirect enabled="true">
<add wildcard="/" destination="/menu_1/MainScreen.aspx" />
</httpRedirect>
</system.webServer>
Note that you need to have the "HTTP Redirection" feature enabled on IIS - see HTTP Redirects