27 April 2013
Category:
Apache
Linux
Comments: Comments Off on Redirect www to non www with .htacess

Redirect www to non www with .htacess

htaccess

Google consider www and non www domain’s as separate. So sometimes you may want to redirect all your www url to non www url i.e http://www.domain.com to http://domain.com

You can easily do it by adding the below code to your .htaccess files.

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

Comments are closed.