IIS7 URL 从根目录重定向到子目录

编程入门 行业动态 更新时间:2024-10-18 22:30:37
本文介绍了IIS7 URL 从根目录重定向到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用带有 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 从根目录重定向到子目录

本文发布于:2023-11-01 02:06:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子目录   根目录   重定向   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!