簡體   English   中英

IIS URL用查詢字符串將一個文件夾和子內容重寫到另一個域

[英]IIS url rewrite one folder and subcontent to another domain with query string

我已經在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文件夾重定向此文件夾在遠程上不存在

最后,我通過以下方法解決了

<?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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM