Redirect www URLs to non-www

In order to redirect all requests for www.yourdomain.com to yourdomain.com, you should set the appropriate rewrite rule. This can be done by adding the following lines at the beginning of the .htaccess file in your public_html folder:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

When someone accesses http://www.yourdomain.com s/he will be redirected to http://yourdomain.com.

Using this method is safe because it should not create any redirection loops nor it should interfere with other rewrite rules.

Was this answer helpful?

 Print this Article

Also Read

Modify Nameservers from Client Area

You can change the nameservers of your registered domain from client area itself. For that, you...

Updating DNS at GoDaddy.com

This demo assumes you have a domain name registered through GoDaddy.com, and starts from the...

Updating DNS at MelbourneIT.com.au

This demo assumes you have a domain name registered through MelbourneIT.com.au, and starts from...

How do I set up URL redirect for a domain?

You can redirect the old domain name to your new one by inserting this code to the .htacess file...

Updating DNS at NetworkSolutions.com

This demo assumes you have a domain name registered through NetworkSolutions.com, and starts from...