How do I remove www from all my urls so that search engine can only rank domain.com ?

How do I remove www from all my urls so that search engine can only rank domain.com/ urls under Linux Apache web server?

Add following code to your .htaccess or httpd.conf (directory directive) file:

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

If you added directives to httpd.conf, restart Apache:

# service httpd restart

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.