How to allow only certain files in Apache?

How to allow only certain files in Apache

  • I'd like to filter access to certain files in apache. I want only CGI access. So I tried putting in vhost file: <FilesMatch "\.cgi$"> Order allow,deny Allow from all </FilesMatch> <FilesMatch "."> # All other files Order allow,deny Deny from all </FilesMatch> But the latter overrides it all. Thanks

  • Answer:

    I believe you need to swap the values in your Order directive as follows: <FilesMatch "\.cgi$"> Order Deny,Allow Allow from all </FilesMatch> <FilesMatch "."> # All other files Order Deny,Allow Deny from all </FilesMatch> This will by default deny all access for all files. Any file ending in .cgi will then be allowed. See the http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order for more info.

Himberjack at Server Fault Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.