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

查看:189
本文介绍了从根目录到子目录的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>

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

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