How to 301 Redirect Non-WWW to WWW URLs

1.Find .htaccess file in root folder
2.Open .htaccess file
3.Delete all content
4.Type in this code(using your domain ):

Code (text):

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteBase /

 

RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC]

RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

 

</IfModule>

5.Save the file
6.Put file in root folder
7.Upload file on the server( make sure you put .htaccess file in the root folder…
How to 301 Redirect Non-WWW to WWW URLs

See original post by kesb

Leave a Reply