Regex to allow all php files except one

Posted by Tim on Stack Overflow See other posts from Stack Overflow or by Tim
Published on 2010-05-21T09:25:46Z Indexed on 2010/05/22 0:40 UTC
Read the original article Hit count: 267

Filed under:
|

Hi all,

I have this regex that allow all php files :

^.*\.([Pp][Hh][Pp])

how can I exclude a specific file, for example test.php ?

Thanks for your answer, Best regards

[edit] I omit to say that it is a reg from a htaccess file, the /i doesn't seems to work, and the ? neither. [Edit2] the purpose is to grant access to authenticated users, except for one file that has to be allowed for everyone. So I've done :

<Files ~ "^.*\.([Pp][Hh][Pp])$">
AuthUserFile /directory/.htpasswd
AuthGroupFile /dev/null
AuthName "Please log in ..."
AuthType Basic
require valid-user
</Files>

So, all php files require valid user. I would like to add an exception for a specific file, says test.php

© Stack Overflow or respective owner

Related posts about regex

Related posts about .htaccess