Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache filesmatch directive help. Want to include the "path/to/file" but not working right

I would like to prevent direct url access to some selected directories. But then make a few files inside the chosen directories accessible for direct url access. I'm having some trouble writing the < filesmatch > portion to allow access to the .php files inside the "xml/" directory. I'm wanting to include part of the "path" in the filesmatch directive, rather than create separate < directorymatch > directives for each directory i want certain files availabe in, but it doesn't work...works if I remove the "/xml/" and put <FilesMatch "\.(php)$">

In my httpd.conf I have a virtual directory set up. Inside the virtual directory I added the following:

<DirectoryMatch "^/data/servers/dev.site.com/web/administrator/(includes|xml|css|javascript|stylesheet|cache|classes|acco
unt_files)">
        AddType application/x-httpd-php .php .html .htm
        Options none
        AllowOverride All
        Order Deny,Allow
        Deny from all


        #Target all files in "xml/" directory that end in ".php"
        <FilesMatch "/xml/\.(php)">
                AddType application/x-httpd-php .php
                Order Allow,Deny
                Allow from all
        </FilesMatch>

</DirectoryMatch>

Anyone know how I should write this?

Thanks for the help.

like image 385
Ronedog Avatar asked Jan 26 '11 17:01

Ronedog


1 Answers

FilesMatch works purely on filenames - it doesn't look at the path portion at all, so you'll never get an '/xml/' in a filename in the FilesMatch block. That's why there's DirectoryMatch above. Match the directory there, then match filenames within the dirmatch.

like image 107
Marc B Avatar answered Oct 15 '22 09:10

Marc B