Regular expressions in <FilesMatch> directive
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Web Servers General Talk > Regular expressions in <FilesMatch> directive




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Regular expressions in <FilesMatch> directive  
Joe


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-15-04 11:00 PM

Using Apache 2.0 I'm attempting to require user validation for access
to files in a directory "except" those with a ".txt" extension.  I've
tried all kinds of "regular expressions" in the "FilesMatch" directive
in the .htaccess file, some with limited success.

I thought <FilesMatch "!(\.txt$)"> would yield a match for all files
that do not end with ".txt".  This does not work; however, if I use
<FilesMatch "\.txt$"> I can match all files that do end with ".txt".

What I have found is that whenever I use the "!" in a regular
expression I do not get the results I'm expecting.  Is the use of
regular expressions in <Files> and/or <FilesMatch> limited such that
"!" is not going to work?

I've tried getting this to work using Apache 1.3 and Apache 2.0 on
both Win32 and OpenVMS systems.

I'd appreciate some direction on this one.  My .conf file and
.htaccess files follow.

Thank you.

My joe.conf file includes...

<Directory "C:/Apache/test" >
Options Indexes Includes ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Alias /test "C:/Apache/test"

<Directory /test/userdir >
AllowOverride None
Options Indexes MultiViews
</Directory>

#
# Require username/password
# (defined in C:\Apache\test\userdir1\.htaccess)
#
<Directory /test/userdir1 >
Options Indexes Includes MultiViews
AllowOverride AuthConfig
</Directory>


My C:\Apache\test\userdir1\.htaccess file contains...

AuthType Basic
AuthName "The Big Authority"
AuthUserFile "C:/Apache/joespasswords.txt"
<FilesMatch "!(\.txt$)">
require valid-user
</FilesMatch>





[ Post a follow-up to this message ]



    Re: Regular expressions in <FilesMatch> directive  
Klaus Johannes Rusch


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-16-04 10:56 PM

Joe wrote:

> Using Apache 2.0 I'm attempting to require user validation for access
> to files in a directory "except" those with a ".txt" extension.  I've
> tried all kinds of "regular expressions" in the "FilesMatch" directive
> in the .htaccess file, some with limited success.
>
> I thought <FilesMatch "!(\.txt$)"> would yield a match for all files
> that do not end with ".txt".  This does not work; however, if I use
> <FilesMatch "\.txt$"> I can match all files that do end with ".txt".
>
> What I have found is that whenever I use the "!" in a regular
> expression I do not get the results I'm expecting.  Is the use of
> regular expressions in <Files> and/or <FilesMatch> limited such that
> "!" is not going to work?

Negation of the whole pattern is not supported by regular expressions,
some applications allow a leading exclamation mark to invert the result
of a regular expression pattern match.

An alternate approach is to apply rules to all files, then override with
the default for the files you want to exclude.

--
Klaus Johannes Rusch
KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:03 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register