2

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>
CEich
  • 123
  • 1
  • 4

3 Answers3

3

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>
coredump
  • 12,573
  • 2
  • 34
  • 53
1

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

<FilesMatch "(?!sitemap)\.xml$">
Ap.Muthu
  • 26
  • 1
0

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.

CEich
  • 123
  • 1
  • 4
  • Don't you mane "Deny from all" on line 3? – Peter Ajtai Aug 01 '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 03 '10 at 15:03