Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't .htaccess have any effect?

I have a .htaccess file in a directory, but it has no effect (no matter what I put in it).

My apache2.conf file contains

AccessFileName .htaccess

<Directory "/var/www">
    AllowOverride All
</Directory>

It already said AccessFileName .htaccess but I added the Directory tag myself, thus I'm not sure if it's correct.

Thanks for any advice and requests for more information.

My .htaccess content (for now)

Options +FollowSymlinks
RewriteEngine on

RewriteRule .* page.php?arg=$0
like image 286
Hubro Avatar asked Nov 06 '10 03:11

Hubro


People also ask

Why is my htaccess not working?

Improper syntax being used It is quite common for a syntax error to be the reason for an . htaccess file not working. If you are familiar with how to read and configure . htaccess rules, double check your configuration.

How do I know if .htaccess is working?

Save the file and type the URL yoursite.com/foobar/ . If the reditect works and the URL gets redireted to the homepage of example.com then it's clear that your htaccess is working and being read by your Apache server. If it still doesn't work then the problem might be that your hosting provider has not enabled it.

How long does it take for .htaccess to update?

htaccess files follow the same syntax as the main configuration files. Since . htaccess files are read on every request, changes made in these files take immediate effect.


1 Answers

You're on Debian, according to your tags. The default site, at least on Lenny in its default configuration of apache2, is defined in /etc/apache2/sites-available/000-default. This default has AllowOverride None in the section for the /var/www directory. So, that could be overriding your apache2.conf.

Of course, you would need to ensure that the site is enabled. If /etc/apache2/sites-enabled/000-default exists and is a symlink pointing to /etc/apache2/sites-available/000-default, then the site is enabled. The canonical way to enable such a site is, as root, a2ensite 000-default.

Finally, realize that if you have access to the main configuration, for performance reasons, you should configure your site using the main configuration (or the site configurations in /etc/apache2/sites-available) rather than in .htaccess. See http://httpd.apache.org/docs/2.2/howto/htaccess.html for further explanation.

like image 113
Andrew Avatar answered Sep 26 '22 01:09

Andrew