PDA

View Full Version : Disable files from Apache


b_r_h
08-11-2009, 11:20 AM
Hello,

I have tried and read many articles about disabling files from apache, but I didn't manage it work.

This one taken from httpd.conf is working ok. I cannot even with direct reference see file eg. http://myserver/.htfile

<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>


but if I change this to files con, it's not working I cannot see in directory listing, but can direct read it. http://myserver/conn.inc

<FilesMatch "^\co">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>


My coal is totally apache ignore my *.inc -files. I have tried following, with no success

<FilesMatch "\.inc">
Order Allow,Deny
Deny from all
</FilesMatch>


There must be something I cannot see?

tomws
08-11-2009, 05:32 PM
Those are regex patterns, so they need to be looked at differently.

<FilesMatch "^\.ht">

The backslash in that one is escaping the special character '.' so that it's interpreted as a literal dot.

<FilesMatch "^\co">


Backslash-c is not what you want to block. Remove the slash and see how it works. If you're just trying to restrict access to a single file, though, then try the Files block. Here's one of mine:
<Files "cron.php">


<FilesMatch "\.inc">
That's just looking for files named '.inc' - not very useful. You want to restrict all files ending with .inc. I think it might look like this:
<FilesMatch ".*\.inc$">
Dot-star means any characters. Backslash-dot means dot. 'inc' is just those characters. $ means end.

Regex confuses me since I don't use them very often, so it may close but still wrong.

b_r_h
08-12-2009, 08:57 AM
Thank's!

Both of yours sampes are working ok


<FilesMatch "^co">

This ignoring all files started with co


<FilesMatch ".*\.inc$">

And this ignoring files ending .inc

One more - one of my long time problem:

<FilesMatch ".*\.php~$">

Using tomws samples, this also resolving .php~ (backup files) showing to browser.