HTACCESS | Redirect naked domain to WWW - [NON WWW to WWW with htaccess]

Published

Here is how you can redirect your named domain address to www Using .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]




Code explained:

RewriteEngine On : 
Enable URL rewriting

RewriteCond %{HTTP_HOST} !^www\. [NC] : Condition Checking whether the current requested address contains WWW or not.

RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] : If there is no WWW , adding WWW in front of domain name and appending requested address, then redirecting to that address with a permanent redirect.


Comments

Post a Comment