IIS URL rewrite one folder and sub-content to another domain with query string
I had one Wordpress Blog hosted on an IIS server and moved to a managed hosting. So I need one URL rewrite to redirect all the request to new domain's exact location.In my scenario, my existing blog domain name is https://spiderip.com/blog and need to redirect all the request to https://blog.spiderip.com with the query.To complete this Follow the steps
- Open IIS and navigate to spiderip.com and click the "blog" folder
- On the right Feature view click "URL Rewrite"
3.Click "Add Rule(s)" and select " Blank Rule"
On pattern type
.*
on Condition Type "Condition Input as"
{HTTP_HOST}{REQUEST_URI}
and pattern as
(.*)/blog/(.*)
Select "Action properies" as "redirect" and enter the following as "Redirect URL"
https://blog.spiderip.com/{C:2}
Final web config looks like
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<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>
Comments