IIS7 URL 重定向从根目录到子目录 [英] IIS7 URL Redirection from root to sub directory

查看:32
本文介绍了IIS7 URL 重定向从根目录到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 IIS7 的 Windows Server 2008.我需要将访问 www.mysite.com 的用户重定向到 www.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>

这篇关于IIS7 URL 重定向从根目录到子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆