You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by John Walton <li...@gmail.com> on 2006/03/29 22:06:39 UTC

[users@httpd] .htaccess and case-insensitive regular expression matching

Hi,

I'm trying to create a .htaccess file that will reside in an /images
directory.  I want the .htaccess file to only deny access to everything
EXCEPT image files (gif, jpg, bmp, png, etc).  I've searched the web, apache
manual, and PCRE manual for hours but for the life of me I can't get the
regular expression to do a case-insensitive match with the FilesMatch
directive.  The file I created below does this trick so long as the file
extension is lower-case.  I tried changing the regular expression below to
"(?i)\.(gif|jpe?g|png|bmp)$" and "\.(?i:gif|jpe?g|png|bmp)$" but that causes
an internal server error.  The web server is running Apache 1.3 on FreeBSD
4.7.

.htaccess file:
Deny from all
<FilesMatch "\.(gif|jpe?g|png|bmp)$">
  Allow from all
</FilesMatch>


Thanks for your help!
John

Re: [users@httpd] .htaccess and case-insensitive regular expression matching

Posted by Joshua Slive <jo...@slive.ca>.
On 3/29/06, John Walton <li...@gmail.com> wrote:
> Hi,
>
>  I'm trying to create a .htaccess file that will reside in an /images
> directory.  I want the .htaccess file to only deny access to everything
> EXCEPT image files (gif, jpg, bmp, png, etc).  I've searched the web, apache
> manual, and PCRE manual for hours but for the life of me I can't get the
> regular expression to do a case-insensitive match with the FilesMatch
> directive.  The file I created below does this trick so long as the file
> extension is lower-case.  I tried changing the regular expression below to
> "(?i)\.(gif|jpe?g|png|bmp)$" and "\.(?i:gif|jpe?g|png|bmp)$" but that causes
> an internal server error.  The web server is running Apache 1.3 on FreeBSD
> 4.7.

Apache 1.3 uses HSRegex or your system egrep-compatible regex library.
 These are much less capable than PCRE and they do not support the ?i
flag.  So you are out of luck unless you want to upgrade.

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
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org