Redirect domain, add www

If you want to redirect your website’s visitors to your www domain name, add this in your apache virtualhost configuration

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

and don’t forget to enable rewrite module

a2enmod rewrite

Leave a Reply