You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jean-Gabriel Duquesnoy <je...@duquesnoy.de> on 2001/12/13 18:22:45 UTC

Syntax for directive

Hi,

I need some information about the regular expression syntax for a
<FilesMatch>
directive. I need to enable authentication for specific files within a
directory
and though the <FilesMatch> directive would be the right one, but I have
tried
several expressions to match my expectations, and none has given the
expected
results. The files I want to protect have the following naming convention:
add*.php, amend*.php and del*.php
I have tried with:
<FilesMatch "(add|amend|del)*.php $">
	AuthType Basic
	AuthName "Authentication Required"
	AuthUserFile /usr/local/apache/passwd/passwords
	Require valid-user
</FilesMatch>

But the files are still accessible without the user being asked for
credentials.
I have managed to set it up for a directory, so I know it works, but I have
probably
an error or mistake in my expression "(add|amend|del)*.php $".
Could anyone help me out there or tell me where I can find explanation about
the
syntax of that piece.

Many thanx in advance.

Jean-Gabriel


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Syntax for directive

Posted by darren chamberlain <dl...@users.sourceforge.net>.
Joshua Slive <jo...@slive.ca> said something to this effect on 12/13/2001:
> > From: Jean-Gabriel Duquesnoy [mailto:jean-gabriel@duquesnoy.de]
> > <FilesMatch "(add|amend|del)*.php $">
> 
> Here's my educated guess:
[-- snip --]
> What you probably want is
> <FilesMatch "(add|amend|del).*\.php$">

I'd add that the space between "php" and "$" is also causing you
some problems; Joshua fixed it in his example.

(darren)

-- 
All truth passes through three stages: first, it is ridiculed; next it
is violently attacked; finally, it is held to be self-evident.
    -- Schopenhauer

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: Syntax for directive

Posted by Joshua Slive <jo...@slive.ca>.

> From: Jean-Gabriel Duquesnoy [mailto:jean-gabriel@duquesnoy.de]

> <FilesMatch "(add|amend|del)*.php $">

Here's my educated guess:

"*" in a regular expression does not mean the same as "*" in the shell.  It
means "match zero or more of the immediately preceeding character/group.  So
your regex matches ".php" "add.php" "addaddaddadd.php" but not "addfoo.php".
The other problem could be the space between php and $.

What you probably want is
<FilesMatch "(add|amend|del).*\.php$">

The "." matches any character, so ".*" matches zero or more of any character
(ie anything).  The "\." matches a literal dot.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org