I have this htaccess rule to block all .xml requests:
<Files ~ "\.xml$">
Order allow,deny
Deny from all
Satisfy all
</Files>
However, I need to allow one certain .xml file. How should the rule be re-written?
Also, above that rule, I have an exception like this:
RewriteRule ^(myxml\.xml)$ $1 [L]
But that still doesn’t allow the file.
The Apache Regexp Engine is PCRE compatible so why not use a regexp with a negative lookbehind assertion
"(?<!\bmyxml)\.xml$"?What this says is match something ending in .xml so long as it’s not preceded by myxml. This means that the rule won’t fire for myxml.xml, so it won’t be denied.
BTW FilesMatch is preferred to Files ~ according to the Apache docs. Don’t ask me why.