How to redirect non-www to www with .htaccess – Come redirigere non-www to www tramite .htaccess

Problem:
How to redirect any requests from http://my-domain.com to http://www.my-domain.com. There are several benefits from doing that:

Solution:
Applied to: Linux apache.

Log on your server and tries on website folder the .htaccess file and edit it:

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

Well done!

Best Regards,
ITquadro – specialized Blog

ITquadro sistemisti specializzati su Bologna ed Emilia-Romagna esperti in installazione e configurazione di server apache su distribuzioni linux basate (Debian, CentOS, ecc).