You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martijn <sw...@googlemail.com> on 2008/03/12 12:59:10 UTC

[users@httpd] FilesMatch matching all but certain extensions

Hello.

Apache 1.3. A simple problem: I want to use a FilesMatch directive to
match all files but, say, images which are either .gif files or .jpg
files.

I tried something like
  <FilesMatch "!\.(jpg|gif)$">
or
  <FilesMatch "!(\.(jpg|gif))$">
but in either case nothing was matched. Putting the exclamation mark
outside the quotes doesn't help either, while removing it altogether
matched only .gif and .jpg files, thus confirming that there is no
typo in that bit.

Any ideas?

Thanks.

Martijn.

---------------------------------------------------------------------
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


Re: [users@httpd] FilesMatch matching all but certain extensions

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Wed, 2008-03-12 at 11:59 +0000, Martijn wrote:
> Hello.
> 
> Apache 1.3. A simple problem: I want to use a FilesMatch directive to
> match all files but, say, images which are either .gif files or .jpg
> files.
> 
> I tried something like
>   <FilesMatch "!\.(jpg|gif)$">
> or
>   <FilesMatch "!(\.(jpg|gif))$">

try with

(.*)\.(gif|jpg|jpeg)

salu2

> but in either case nothing was matched. Putting the exclamation mark
> outside the quotes doesn't help either, while removing it altogether
> matched only .gif and .jpg files, thus confirming that there is no
> typo in that bit.
> 
> Any ideas?
> 
> Thanks.
> 
> Martijn.
> 
> ---------------------------------------------------------------------
> 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
> 
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
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


Re: [users@httpd] FilesMatch matching all but certain extensions

Posted by Martijn <sw...@googlemail.com>.
On Wed, Mar 12, 2008 at 4:34 PM, Joshua Slive <jo...@slive.ca> wrote:
>  Well, you're not really being specific about the issue.

I am not. Sorry for that. The thing is that there isn't really an
actual 'issue': the server is running well, but can do with some
improvement. (Which server can't?) Therefore I wanted to see, on a
development machine, if excluding the images from the handlers would
make a significant difference.

I am aware of other ways of achieving the same, these haven't worked
with me for other (non-Apache) reasons; hence I thought regex negation
would be a simple idea.

I could not find anywhere -neither in documentation, nor on the
internet- whether regex negation is possible in Apache 1.3. Thanks to
your reply, the answer should now be available through the archives of
this mailing list.

Thanks.

Martijn.

---------------------------------------------------------------------
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


Re: [users@httpd] FilesMatch matching all but certain extensions

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, Mar 12, 2008 at 10:34 AM, Martijn <sw...@googlemail.com> wrote:
> On Wed, Mar 12, 2008 at 1:50 PM, Joshua Slive wrote:
>  >  If you told us exactly what you are trying to do, we might be able to
>  >  suggest a word-around.
>
>  There are several things happening during Apache's request cycle:
>  session management, authentication, authorization etcetera, mostly
>  through mod_perl modules, all in a <Location />-directive. There is no
>  need to do all that for images (or .css files, .js files and some
>  more) and I have found images load significantly faster if I remove
>  the whole <Location /> block. (The rest of the site, obviously, then
>  stops working.) Which hopefully explains why I wanted to exclude these
>  files from the directive.
>
>  Of course, I can replace the Location-directive by a LocationMatch or
>  a DirectoryMatch and positively match all the locations or directories
>  that need to be 'handled'. Due to the directory-structure of our
>  server, I think regex negation would be a lot easier. If it were
>  possible in Apache 1.3 that is.

Well, you're not really being specific about the issue.

Often times you can undue one section with another one. For example,
if your complex processing is being invoked with a handler, you can
undo it with
<FilesMatch \.jpg$>
SetHandler default-handler
</FilesMatch>

mod_perl can probably do something similar, but I don't know the details.

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


Re: [users@httpd] FilesMatch matching all but certain extensions

Posted by Martijn <sw...@googlemail.com>.
On Wed, Mar 12, 2008 at 1:50 PM, Joshua Slive wrote:
>  If you told us exactly what you are trying to do, we might be able to
>  suggest a word-around.

There are several things happening during Apache's request cycle:
session management, authentication, authorization etcetera, mostly
through mod_perl modules, all in a <Location />-directive. There is no
need to do all that for images (or .css files, .js files and some
more) and I have found images load significantly faster if I remove
the whole <Location /> block. (The rest of the site, obviously, then
stops working.) Which hopefully explains why I wanted to exclude these
files from the directive.

Of course, I can replace the Location-directive by a LocationMatch or
a DirectoryMatch and positively match all the locations or directories
that need to be 'handled'. Due to the directory-structure of our
server, I think regex negation would be a lot easier. If it were
possible in Apache 1.3 that is.

Martijn.

---------------------------------------------------------------------
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


Re: [users@httpd] FilesMatch matching all but certain extensions

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, Mar 12, 2008 at 7:59 AM, Martijn <sw...@googlemail.com> wrote:
> Hello.
>
>  Apache 1.3. A simple problem: I want to use a FilesMatch directive to
>  match all files but, say, images which are either .gif files or .jpg
>  files.
>
>  I tried something like
>   <FilesMatch "!\.(jpg|gif)$">
>  or
>   <FilesMatch "!(\.(jpg|gif))$">
>  but in either case nothing was matched. Putting the exclamation mark
>  outside the quotes doesn't help either, while removing it altogether
>  matched only .gif and .jpg files, thus confirming that there is no
>  typo in that bit.
>
>  Any ideas?

FilesMatch does not support regex negation. In modern versions of
apache (2.x), you can use negative lookahead regexes. But your version
is not modern.

If you told us exactly what you are trying to do, we might be able to
suggest a word-around.

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