Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

Deny access to all directory files BUT a certain suffix?

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


tom.browder at gmail

Aug 5, 2012, 2:31 PM

Post #1 of 3 (489 views)
Permalink
Deny access to all directory files BUT a certain suffix?

I see lots of examples of denying access to files in a directory with
a certain suffix, but I want to deny access to ALL files EXCEPT those
with one suffix (.html).

I have tried this (Apache 2.2.14):

<Directory ~ ".*/private2">

SSLOptions +StdEnvVars +StrictRequire +OptRenegotiate

SSLVerifyClient require
SSLVerifyDepth 1

# do NOT allow dir listings
Options -Indexes

# do not allow access to any but .html files
<FilesMatch "(?!\.html$)">
Order allow,deny
Deny from all
</FilesMatch>

</Directory>

But I still can see the README.txt file I have in that directory (I
know most recommend not putting any files there that are not to be
seen).

I must have something messed up (probably the regex, but it does work
for me in a Perl script) but I don't know the correct way.

Thanks for any help.

Best regards,

-Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


rumble at cord

Aug 5, 2012, 2:43 PM

Post #2 of 3 (472 views)
Permalink
Re: Deny access to all directory files BUT a certain suffix? [In reply to]

On 08/05/2012 11:31 PM, Tom Browder wrote:
> I see lots of examples of denying access to files in a directory with
> a certain suffix, but I want to deny access to ALL files EXCEPT those
> with one suffix (.html).
>
> I have tried this (Apache 2.2.14):
>
> <Directory ~ ".*/private2">
>
> SSLOptions +StdEnvVars +StrictRequire +OptRenegotiate
>
> SSLVerifyClient require
> SSLVerifyDepth 1
>
> # do NOT allow dir listings
> Options -Indexes
>
> # do not allow access to any but .html files
> <FilesMatch "(?!\.html$)">
> Order allow,deny
> Deny from all
> </FilesMatch>
>
> </Directory>
>
> But I still can see the README.txt file I have in that directory (I
> know most recommend not putting any files there that are not to be
> seen).
>
> I must have something messed up (probably the regex, but it does work
> for me in a Perl script) but I don't know the correct way.
>
> Thanks for any help.
>
> Best regards,
>
> -Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
Try <FilesMatch ".+\.(?!html).+$">
It might need some work, as it will only block files that follow the
prefix.suffix standard, but it's a working start :)

With regards,
Daniel.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


tom.browder at gmail

Aug 5, 2012, 3:24 PM

Post #3 of 3 (473 views)
Permalink
Re: Deny access to all directory files BUT a certain suffix? [In reply to]

On Sun, Aug 5, 2012 at 4:43 PM, Daniel Gruno <rumble [at] cord> wrote:
> On 08/05/2012 11:31 PM, Tom Browder wrote:
>> I see lots of examples of denying access to files in a directory with
>> a certain suffix, but I want to deny access to ALL files EXCEPT those
>> with one suffix (.html).
...
> Try <FilesMatch ".+\.(?!html).+$">
> It might need some work, as it will only block files that follow the
> prefix.suffix standard, but it's a working start :)

That seems to have done the trick for my purposes, Daniel!

Thanks very much.

Best regards,

-Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.