cwmoh
By:
cwmoh

redirecting non www to www domain

August 6, 2013 2.5k views
I have co.in domain and this added in digital ocean DNS and also virtual hosts configured as below ServerAdmin webmaster@example.co.in ServerName example.co.in ServerAlias www.example.co.in But non www is not redirecting to www domain.co.in.please let me know why this is not working. but www version is working perfectly. my .htaccess file also given below RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^www\..+$ [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
3 Answers
Add RewriteEngine On at the top of your .htaccess file and run this command as root:

a2enmod rewrite


Make sure you have AllowOverride All in your Virtualhost config.

Finally, restart apache:
sudo service apache2 restart
I have a Wordpress installation.
How can I configure the AllowOverride parameter?
Run
sudo nano $(ls -1d /tmp/aioefjaisjf/* | grep -v default)
and set AllowOverride to All.
Have another answer? Share your knowledge.