Rewriting URLs to redirect HTTP requests

I have just updated my old blog site to redirect all the requests to the new one. It has been very easy as the only change to do implies the inclusion of a "rule" in the "rewrite" section of the web.config file. Here is the code:

<webServer>
<!-- Rest of settings -->
<rules>
	<clear />
    <rule name="Redirect requests from jamuro-blog to jamuro-blognet" stopProcessing="true">
    <match url="(.*)" />  
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="^jamuro-blog\.azurewebsites\.net$" />
    </conditions>
    <action type="Redirect" url="http://jamuro-blognet.azurewebsites.net/{R:0}" />  
    </rule>  
	<!-- Rest of rules -->
</rules>
<!-- Rest of settings -->
</webServer>

The rule intercepts all the requests matching a pattern (^jamuro-blog\.azurewebsites\.net$) and then, redirect to the new site as per settings defined in the proper action section.

On the other hand, I updated my configuration in Google Search Console to inform my old site was going to be redirected. It is important for search engines to know it so that you can keep receiving visits properly.

References

Creating Rewrite Rules for the URL Rewrite Module

Add comment