从根目录到子目录的IIS7 URL重定向
我正在将Windows Server 2008与IIS7一起使用.我需要将进入www.mysite.com
的用户重定向到wwww.mysite.com/menu_1/MainScreen.aspx
.这是我在项目中使用的文件结构:
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.
在这里.将此代码添加到您的 web.config 文件:
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>
它将执行301永久重定向(URL将在浏览器中更改).如果要使这种重定向"不可见(重写,内部重定向),请使用此规则(唯一的区别是重定向"已由重写"代替):
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>