Force URLs with www. for without the www. with htaccess

4

I would like that when typing in the URL link .htaccess would always redirect to link , I need this extra 4 characters for the ad campaigns.

The opposite of .htaccess is this way:

RewriteEngine on
RewriteBase /
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^meusite.com.br [NC]
RewriteRule ^(.*)$ http://www.meusite.com.br/$1 [R=301,L] 

This above, redirects from link to

    
asked by anonymous 21.09.2015 / 15:49

1 answer

5

Just change the regular expression and redirect URL.

RewriteEngine on
RewriteBase /
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www.meusite.com.br [NC]
RewriteRule ^(.*)$ http://meusite.com.br/$1 [R=301,L] 
    
21.09.2015 / 15:57