Reputation: 792
I've installed lamp on an UBUNTU 12.04 64bit Server using tasksel. Everything is working properly. But Now I found that per-directory .htaccess apache overriding thing is not working.
I've searched on google about the possible cause.
http://www.cyberciti.biz/faq/apache-htaccess/
http://smartwebdeveloper.com/apache/htaccess-problems
But none of them is working.
I need to redirect domain.com to www.domain.com. So, I'm using the following code in my .htaccess file at server root
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
RewriteEngine On
RewriteBase /
# Redirect to www.
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
</IfModule>
Apache virtual host configuration:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride ALL
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Order allow,deny
allow from all
</Directory>
...........................
...........................
...........................
apacha2.conf has this:
AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
Upvotes: 1
Views: 1000
Reputation: 3665
Everything looks like it's set up correctly, so chances are that mod_rewrite
is not enabled. Try running sudo a2enmod rewrite
from the terminal.
Also, don't forget to reload apache (sudo service apache2 reload
) and then restart apache (sudo service apache2 restart
) after you make changes to any of the files you listed (not .htaccess
files since they are read on every request, but the rest of the files you listed).
HTH. :)
Upvotes: 1