Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to use mod_rewrite through the .htaccess files and I have a big problem, the .htaccess files don't seems to be read. The machine is running Debian 5.0 and it's using the stable apache2 package.

I've followed instructions from this page: http://www.debian-administration.org/articles/136. Enabled mod_rewrite like that:

a2enmod rewrite

In my /etc/apache2/apache2.conf file I've added this:

<Directory "/var/www">
  AllowOverride ALL
  Options FollowSymLinks
</Directory>

In the root directory, I've created a .htaccess file with this content:

RewriteEngine on
RewriteRule ^test$ foo.html

I've tried lots of suggestion from answers to similar questions to no avail. The error message I get when visiting foo.com/test is a 404 Page Not Found. All files are readable by everyone. There's no problem when accessing foo.html directly. I've also tried to put garbage in another .htaccess to see if apache would complains about it, nothing changed. Maybe I'm just too tired!

Thanks

share|improve this question

3 Answers 3

up vote 2 down vote accepted

If you don't get a 500 error when accessing a directory with a .htaccess file with garbage in it then Apache isn't reading your .htaccess file.

Do you have a site defined in the /etc/apache2/sites-available/default file (or whatever file is being used for your virtual host) which overwrites the AllowOverride All definition for that directory ?

share|improve this answer

Check your error file /var/log/apache2/error.log when you try to call "test" check if matches the correct directory.

share|improve this answer

I had a problem with my apache server not reading the htaccess as well, and as it turned out for me, I hadn't set:

<Directory "YOUR_DIRECTORY">
  AllowOverride ALL
</Directory>

for my directory in httpd.conf. But once I did and restarted apache with

apachetcl -k restart

the htaccess worked fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.