Asp.net 子目录到子域重定向的web.config规则

Asp.net 子目录到子域重定向的web.config规则,asp.net,iis,web-config,redirect,Asp.net,Iis,Web Config,Redirect,我已经在下面的路径下运行了一个子网站 现在,我已经创建了一个子域 需要“web.config”文件代码,可以按以下方式执行301操作 Request Redirect to -------------------------------------------------------------------------- http://example.com/sub-site/ http:/

我已经在下面的路径下运行了一个子网站

现在,我已经创建了一个子域

需要“web.config”文件代码,可以按以下方式执行301操作

Request                                     Redirect to
--------------------------------------------------------------------------
http://example.com/sub-site/                http://sub-site.example.com/
http://example.com/sub-site/page-1.html     http://sub-site.example.com/page-1.html
http://example.com/sub-site/page-2.html     http://sub-site.example.com/page-2.html
.
.
.
http://example.com/sub-site/page-N.html     http://sub-site.example.com/page-N.html
基本上,规则的编写方式应该是“http://example.com/sub-site/“已更改为”http://sub-site.example.com/在请求中,浏览器应重定向到较新的位置。

这应该可以工作

    <rewrite>
        <rules>
            <rule name="redirect to subdomain" stopProcessing="true">
                <match url="(.*)" />
                <action type="Redirect" url="http://sub-site./{R:1}" appendQueryString="false" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>