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.

Is there a way to override an htaccess file in a subdirectory? Been Googling for the past couple hours and turned up nothing useful.

I want to block some IP's & unwanted bots, but my 403 page is in a subdirectory, so I have to override the Deny's in it but Allow from all doesn't seem to undo the Deny's. Here's the code I've been trying:

/public_html/.htaccess

<Limit GET POST>
Order Allow, Deny
Allow from all
Deny from 111.13.8.*
</LIMIT>

<Files "/errors/">
Order Allow, Deny
Allow from all
</Files>

It returns a 500 error. Since the bot can't access the errors subdirectory's htacess file, this code would have to go here.

share|improve this question

migrated from stackoverflow.com Nov 3 '11 at 12:50

This question came from our site for professional and enthusiast programmers.

2 Answers 2

I think you want

<Files "/errors/*">

instead of

<Files "/errors/">
share|improve this answer

You could shrink your .htaccess to just

<Limit GET POST>
Deny from 111.13.8.*
</LIMIT>

And you can have a .htaccess in each subdir, so you could do in subdir errors:

<Limit GET>
Allow from *
</LIMIT>

See http://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess.html for usage of the Files directive.

All with the assumption that you are allowed to override directives in your public_html directories at all.

share|improve this answer

Your Answer

 
discard

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