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 recently had a Joomla site hacked, so I'm trying to harden the site a bit. There's a section in the recommended .htaccess that restricts outside access to the xml files that come with extensions. However, it also keeps my sitemap.xml file from being accessed.

How do I allow a certain file whiles keeping the rest?

here's the default code:

<Files ~ "\.xml$">
 Order allow,deny
 Deny from all
 Satisfy all
</Files>

and my modification that caused a 500 error:

<Files ~ "(?!sitemap)\.xml$">
 Order allow,deny
 Deny from all
 Satisfy all
</Files>
share|improve this question
    
Care to specify what the error message is? You'll find it in your error_log. –  tylerl Jul 31 '10 at 8:02
add comment

3 Answers

up vote 0 down vote accepted

The FilesMatch line has an extra "<". It should be:

<FilesMatch "(?!sitemap)\.xml$">
share|improve this answer
add comment

You should use <FilesMatch> as documented here

Also, I think your regex should be (?<!sitemap)\.xml$ instead. Like this:

<FilesMatch "(?<!sitemap)\.xml$">
   Order allow,deny
   Deny from all
</FilesMatch>
share|improve this answer
    
Still cased a 500 error for me. –  CEich Jul 31 '10 at 7:09
add comment

I finally decided not to mess with the regex.

I added:

<Files ~  "sitemap\.xml$">
  Order allow,deny
  Allow from all  
</Files>

afterward and it works like a charm.

share|improve this answer
    
Don't you mane "Deny from all" on line 3? –  Peter Ajtai Aug 1 '10 at 21:25
    
no, putting this under the directive to deny all .xml files overrides the directive in this one case. Thus, though not as cool looking as the regex solution, it still works. –  CEich Aug 3 '10 at 15:03
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.