301 redirect from http(s) non-www to www

How to redirect http:// non-www to http://www?

Add this code into your .htaccess file:

#Always use the www. in the URL address
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

How to redirect http:// non-www to https://www?

Add this code into your .htaccess file:

#Always use the www. in the URL address
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

No related posts.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>