我正在使用带有 IIS7 的 Windows Server 2008.我需要将访问 www.mysite 的用户重定向到 www.mysite/menu_1/MainScreen.aspx.这是我的项目文件结构:
I am using Windows Server 2008 with IIS7. I need to redirect the users who come to www.mysite to wwww.mysite/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>更多推荐
IIS7 URL 重定向从根目录到子目录
发布评论