Monthly Archives: September 2016

Redirect non-www to www in .htaccess

Write this code in root’s .htaccess file it will redirect to www if non-www requests found .. RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] Another solution RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Advertisements

Posted in Apache | Leave a comment