0

I have a .htaccess file that isn't working. I know it's not working because i wrote random things in it and i am not getting a 500 error. Even when i write proper code it doesn't work. I have verified that is in my root directory and has the proper file name. Here is the directory "tag" from http.conf:

<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>

I used <?php phpinfo(); ?> and verified that mod_rewrite is enabled, but still no luck.

4
  • Anything useful in the Apache error log? Jan 20, 2012 at 2:36
  • @ShaneMadden how do i do that. im not getting any error when i run my htaccess in my directory. the pages load like normal
    – user176105
    Jan 20, 2012 at 2:38
  • Open the Apache error log and look for any errors that are relevant. The log's location is variable based on how it was installed and what system you're on. Jan 20, 2012 at 2:40
  • @ShaneMadden it seems that ive gotten about a hundred errors and all of them are the same thing. "[Thu Jan 19 21:50:56 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico"
    – user176105
    Jan 20, 2012 at 2:57

2 Answers 2

1

I wonder if that Deny from all might be the problem. If Apache knows it's going to send a 403 response, it might not even bother reading the .htaccess file.

Other potential problems could include a typo in the name of the .htaccess file (although you did say you'd checked this), a different AccessFileName value to normal and file/directory permissions on any of the directories leading up to your DocumentRoot.

It might be worth using strace to verify that Apache is actually reading your .htaccess file. Make sure Apache is stopped then start it this way:

sudo strace -f -e open apache2 -X

Then make your request again.

1
  • "If Apache knows it's going to send a 403 response, it might not even bother reading the .htaccess file." - That doesn't happen. The .htaccess file could potentially override the Deny from all (defined in a parent directory context).
    – MrWhite
    Jan 26, 2023 at 23:54
1
<Directory />
Options FollowSymLinks
AllowOverride All

You should never set AllowOverride All for the entire filesystem (ie. inside the <Directory /> container). This should be (and defaults to) AllowOverride None for a reason. And Apache explicitly warns against doing this.

Setting AllowOverride All here will cause Apache to scan for .htaccess files all the way up the directory tree to the root.

The most likely reason why your .htaccess file is not being processed is that you have a more specific <Directory> container (possibly in a <VirtualHost>) elsewhere in your config that has set AllowOverride None, overriding the setting in <Directory /> for that directory tree.

However, by setting AllowOverride All in <Directory /> then Apache is quite likely scanning for .htaccess files in all parent directories which could result in performance and security issues.

<Directory />
:
Deny from all

You must have a more specific <Directory> container somewhere since your site is presumably accessible? (I assume you are not getting a "403 Forbidden" response?)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .