Negation in mod_rewrite regex

This is a discussion on Negation in mod_rewrite regex within the Linux Web Servers forums, part of the Web Server and Related Forums category; say that I have this example: /path1/horse/any_path /path1/dog/any_path .... I need to rewrite ANY URL that does ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008
Pan Am
 
Posts: n/a
Default Negation in mod_rewrite regex

say that I have this example:

/path1/horse/any_path
/path1/dog/any_path
....

I need to rewrite ANY URL that does NOT
include "horse" as second path component.
How can that be done with regex and RewriteRule?

tia


  #2 (permalink)  
Old 02-23-2008
phantom
 
Posts: n/a
Default Re: Negation in mod_rewrite regex



Quote:
>
> say that I have this example:
>
> /path1/horse/any_path
> /path1/dog/any_path
> ...
>
> I need to rewrite ANY URL that does NOT
> include "horse" as second path component.


putting this condition before your rewrite rule should do the trick
RewriteCond %{REQUEST_URI} !^/[^/]+/horse/

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:27 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0