iis web.config 将某些域/路径重定向到新域/samepath

Jea*_*net 2 iis redirect web-config url-rewriting

我需要使用 web.config 使用相同的原始路径/文件夹将某个路径/文件夹重定向到新域。

例如:如果检测到 www.domain1.com/path2match1/* 则重定向到:www.newdomain.com/path2match1/* (与在domain1上匹配的路径相同)

例如:当前:www.domain1.com/path2match1/someFileOrFolders/somefile.html 重定向到:www.newdomain.com/path2match1/someFileOrFolders/somefile.html

任何帮助将不胜感激

谢谢

Jea*_*net 5

我自己设法找到了我的问题的答案!(为我欢呼!哈哈)

不管怎样,这是如何做我所要求的:

<rewrite>
    <rules>
        <rule name="NAME" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}{REQUEST_URI}" pattern="(.*)/FOLDER/(.*)" />
            </conditions>
            <action type="Redirect" appendQueryString="false" url="http://DESTINATION-URL.TLD/FOLDERS/{C:2}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)

警告!添加多个标签集或将此代码放置在错误的位置将导致网站生成内部服务器错误,从而使访问者无法访问该网站,直到删除附加标签为止。