I have a Apache webserver with multiple virtual hosts. I want to redirect all my non-www users to the www website. How do I do this?
I cannot hard code the website host in the RewriteRule becuase I have around 10 vhosts. All those vhosts point to the same Directory. The application is such that the website changes according to the domain referred.
The following code strips off www from the website, but i want the reverse to happen, i.e. I want www to be added to the host url if it is not specified.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,NC,L]