Joshua Slive writes:
On 1/30/06, Björn Heller <[EMAIL PROTECTED]> wrote:
Joshua Slive writes:
> On 1/30/06, Björn Heller <[EMAIL PROTECTED]> 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.
I tried your RewriteMatch proposal. It could work with a RewriteCond and a
RewriteRule but this wouldnt change the URL in the user's address bar and
that's what I want.
---------------------------------------------------------------------
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: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]