justintjacob
justintjacob

Reputation: 193

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

I have hosted on a blog on my windows IIS and moved to another hosting and I need to create IIS URL rewrite rile

My Old domain URL is

http://test.com/blog and I need to redirect /blog and subpages request to http://newtest.com suppose someone access

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

I need to redirect to

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

Can somebody please help me.I tried many URL rewrite rules but during redirect it redirect with /blog folder this folder not exist on remote

Upvotes: 0

Views: 547

Answers (1)

justintjacob
justintjacob

Reputation: 193

Finally, I solved by the below method

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

Upvotes: 1

Related Questions