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

I'm running a LAMP server on Fedora 13 that's working fine; however, I just added an ".htaccess" file to my current site's docroot folder that is being completely ignored.

I've tried half a dozen different tests, including this one:

RewriteEngine on
RewriteBase /

RewriteRule ^.*$ index.php

But images and all other pages load fine, and non-existent files still 404. I also tried this:

order deny,allow
deny from all

But every page still loads just fine. Again the .htaccess file is simply ignored 100%.

We put our virtualhost records in /etc/httpd/conf.d/virtual.conf. It looks like this:

NameVirtualHost *

<VirtualHost *>
    ServerName              intranet
    DocumentRoot            /var/www/default
    <Directory "/var/www/default">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName              ourwebsite.com
    DocumentRoot            /var/www/html/ourwebsite.com/docroot
    <Directory "/var/www/html/ourwebsite.com/docroot">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

What else could be causing our server to completely IGNORE the .htaccess file??

Edit:

I changed the .htaccess file to above to better demonstrate that my changes are being ignored. Note that I tried the exact same .htaccess file on the production server and it worked fine.

Edit 2:

OK, I have new information! Just for testing purposes, I went through and temporarily changed EVERY "AllowOverride" directive to AllowOverride All. I figured out that the very first Directory entry seems to overpower all others:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

When I changed that to AllowOverride All, my .htaccess files begin taking effect. It's like all the other AllowOverride All directives in my config files are being ignored!

What Gives??

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

Unbelievable. Remember how I said this is a development server? Yeah.. well here's what my virtual host entry REALLY looks like:

<VirtualHost *>
    ServerName              dev.ourwebsite.com
    DocumentRoot            /var/www/html/dev.ourwebsite.com/docroot
    <Directory "/var/www/html/ourwebsite.com/docroot">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Do you see it? Well I didn't. I FORGOT To change my "Directory" entry to dev.ourwebsite.com instead of ourwebsite.com -- and that made all the difference. I just assumed that Apache would have thrown an error if the directory didn't exist; but that only applies to the DocumentRoot directive. is match-based -- meaning it applies the rules if it matches the incoming request, but otherwise, it doesn't care if you tell it to AllowOverride on magic unicorns.

Let this be a lesson to any others who come looking -- when all else fails, consider the almighty Typo.

share|improve this answer
add comment

Check out if any other "AllowOverride None" presented in 'httpd.conf' above the virtualhosts declaration. Probably, you have "AllowOverride None" in docroot.

share|improve this answer
    
The server I'm working with is a development server, and it's an exact duplicate of our production server. The httpd.conf files are practically identical. The ONLY significant difference is that our "virtual.conf" on this server has fewer entries and each site is prefixed with dev.. Yet the production server works fine, .htaccess files behave precisely as expected, and the development server simply ignores the .htaccess file altogether. –  Brian Lacy Nov 23 '10 at 16:20
add comment

Three guesses:

Is there actually a space after the comma in the line order deny, allow in .htaccess? Apache doesn't like that. For me on F13 I was get 500s.

Do you have a AccessFileName directive anywhere?

If you are using selinux do you have the correct context for the file (ls -lZ)?

share|improve this answer
    
I'm not getting 500 errors. The .htaccess file is simply ignored. And I verified that I did not have a space in there anyway. I know nothing about selinux or contexts, but I looked up how to check and apparently it's Disabled. As for AccessFileName, I'll look around, but as I said in my comment on Denis' answer, the apache configuration for these two servers is effectively identical. –  Brian Lacy Nov 23 '10 at 16:30
    
I've also had issues with the space. It drove me crazy. –  egorgry Nov 23 '10 at 16:32
    
Whoops, correction: I DO have an AccessFileName directive in my httpd.conf. It reads as follows: AccessFileName .htaccess –  Brian Lacy Nov 23 '10 at 16:36
add comment

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.