Security – .htaccess to deny access to most xml files

.htaccessjoomlaSecurity

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>

Best Answer

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

<FilesMatch "(?!sitemap)\.xml$">