I have a shared hosting plan with Windows Server 2008 and IIS7.5, and there is Microsoft rewriting module installed and enabled.
<rewrite>
<rules>
<rule name="myRule" patternSyntax="Wildcard">
<!--Rewriting code-->
</rule>
</rules>
</rewrite>
So, how to redirect mydomain.example/everywhere-in-site/my-page.html to www.mydomain.example/everywhere-in-site/my-page.html with Microsoft rewriting module?
And what if I want to redirect www.mydomain.example/everywhere-in-site/my-page.html to mydomain.example/everywhere-in-site/my-page.html?
To remove the www from a domain and redirect to a "naked domain" you could di it like in the following code snippet:
And the other way around (if you prefer that) to redirect a non-www to one with www:
The
redirectType="Permanent"is of course optional but for SEO and most scenarios I would recommend it.Please see also these Stack Overflow questions/answers: