IIS URL用查询字符串将一个文件夹和子内容重写到另一个域

时间:2019-01-10 10:53:08

标签: url iis url-rewriting

我已经在Windows IIS上的一个博客上托管了一个主机,并移到了另一个主机上,我需要创建IIS URL重写规则

我的旧域网址是

http://test.com/blog,我需要将 / blog 和子页面请求重定向到http://newtest.com 假设有人访问

http://test.com/blog/index.php/2018/12/07/test

我需要重定向到

http://newdomain.com/index.php/2018/12/07/test

有人可以帮我吗。我尝试了许多URL重写规则,但在重定向过程中,它使用 / blog 文件夹重定向,该文件夹在远程

上不存在

1 个答案:

答案 0 :(得分:0)

最后,我通过以下方法解决

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>

        <rewrite>
            <rules>
                <rule name="Blog redirect" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}{REQUEST_URI}" pattern="(.*)/blog/(.*)" />
                    </conditions>
                    <action type="Redirect" url="https://blog.spiderip.com/{C:2}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>