Re: [users@httpd] RedirectMatch wrongly matching single chars of a string?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/30/06, Björn Heller <heller@xxxxxxxxxxxxx> wrote:
> Joshua Slive writes:
>
> > On 1/30/06, Björn Heller <heller@xxxxxxxxxxxxx> wrote:
> >
> >> I want to redirect all requests like
> >> site.com/something,
> >> site.com/something/someotherthing,
> >> site.com/something/xyz/someotherthing
> >>
> >> to site.com/something.html, no matter if or without trailing slash BUT NOT
> >> if the URL is a .gif, .jpg etc.
> >>
> >> So I've got the following RedirectMatch:
> >>
> >> RedirectMatch permanent ^/(.[^/(\.gif)(\.jpg)]*)/?
> >> http://www.site.com/$1.html
> >
> > You need to look again at a regex tutorial.  Stuff inside [] is a
> > character class, not an arbitrary regex.  That means it will match any
> > one of the set of characters included in the class.  You need
> > something more like
> > RedirectMatch permanent ^/(.*(?!\.(gif|jpg)))/?$ http://www.example.com/$1.html
> > I haven't tested that, and the negative-lookahead assertion will
> > certainly only work in httpd 2.x.
> >
> > Another way to do this that doesn't require as much regex magic is
> > RewriteEngine On
> > RewriteCond %{REQUEST_URI} !(gif|jpg)$
> > RewriteRule ^/(.*)/?$ http://www.example.com/$1[R=permanent]
> >
> > Joshua.
>
> Thanks for the reply. Yes, I was wrong with thinking [^gif] would match only
> the whole string. Got that in the meantime. I just tested your proposal but
> it does not work =/ It redirects to /file.gif.html, /file.gif.html.html etc.
> etc. in an infinite loop. ergo: it matches and redirects.

You tried which proposal?  The RewriteRule one can be easily fixed by adding
RewriteCond %{REQUEST_URI} !\.html$

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



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux