Mobile app version of vmapp.org
Login or Join
Cooney921

: 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

@Cooney921

Posted in: #Dns #Domains #Iis #NoWww #Redirects

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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cooney921

2 Comments

Sorted by latest first Latest Oldest Best

 

@Becky754

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".

10% popularity Vote Up Vote Down


 

@Chiappetta492

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>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme