: Should I use IIS or my DNS provider to redirect my naked domain to its www version? How do I get the naked domain for my site that is typed into a browser (example.com) to automatically
How do I get the naked domain for my site that is typed into a browser (example.com) to automatically redirect to mywebsite.com. Would this be done on the internal IIS web server or through the registration service DNS settings?
I use Register.com and I tried asking their technical support, but they did not answer my question with a usable solution.
More posts by @Cooney921
2 Comments
Sorted by latest first Latest Oldest Best
Just try editing .htaccess file.
Just paste the following code in .htaccess file
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ www.example.com/ [L,R=301,NC]
replace "example" with "your domain name".
Would this be done on the internal IIS web server
It's possible. There are several ways. I will show the way where you use the web.config file. In your web.config file put the following code:
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain.com" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" />
</rule>
</rules>
</rewrite>
Or if you want to use regular expressions:
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" />
</rule>
</rules>
</rewrite>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.