With or without WWW - urlrewrite - web.config

If your site is working for both 'www' and without create a file called web.config and put it in your root folder.  Copy this code below into it.

<configuration> <system.webServer> <rewrite> <rules> <rule name="Cannonical URL" stopProcessing="true"> <match url="(.*)" /> <conditions trackAllCaptures="true"> <add input="{HTTP_HOST}" pattern="^[^=www].*\.com$" /> <add input="{HTTP_HOST}" pattern="^([^./]+).([^./]+)$" /> <add input="{HTTPS}" pattern="^OFF" /> </conditions> <action type="Redirect" url="http://www.{C:0}/{R:0}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>

That will force all pages without www to www.domain.com

Was this answer helpful? 0 Users Found This Useful (0 Votes)