htaccess www redirect

  1. Togliere il www
######################### 
# redirect www to no-www 
#########################

redirect to non www
RewriteCond %{HTTP_HOST} ^www.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

2. Aggiungere il www





#########################
# redirect no-www to www
#########################

RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]