Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x support forum
 Helicon Tech : ISAPI_Rewrite 2.x support forum
Subject Topic: simple rule with multiple conditions Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
mosco
Newbie
Newbie


Joined: 13 January 2005
Location: United States
Online Status: Offline
Posts: 26
Posted: 04 August 2008 at 4:49pm | IP Logged Quote mosco

Hi,

I need some help writing a rule to handle the following:

if url does not start with /- then redirect to /redirect.html
if url is /-[number string]/ or /-[number string]/index.html redirect to /redirect.html

otherwise do nothing

So for example mydomain.com/-123456/ or mydomain.com/-123456/index.html would get redirected, but mydomain.com/-123456/somethingelse.html or mydomain.com/-something/somedir would not get redirected.

Thanks!
Back to Top View mosco's Profile Search for other posts by mosco
 
mosco
Newbie
Newbie


Joined: 13 January 2005
Location: United States
Online Status: Offline
Posts: 26
Posted: 05 August 2008 at 1:16pm | IP Logged Quote mosco

I've made some progress to get this to work but I'm stuck on the second rule (with a change needed from what I wanted to do at first), see below:

# if url is /-[number]/ or /-[number]/index.html go to redirect.html

RewriteRule /-(\d+)(/||/index\.html) /redirect.html [I,L]

This rule above works
but the rules below doesn't, the part I can't get right is to avoid redirecting if the / (site root) is called:

# if url doesn't:
# start with /-
# or start with /login
# or is not /
# then go to redirect.html

RewriteRule ^(?!(?:/-|/login)).* /redirect.html [I,L]

How can I get this rule above to also ignore / requests?

Would really appreciate some help,
Thanks.


Back to Top View mosco's Profile Search for other posts by mosco
 
mosco
Newbie
Newbie


Joined: 13 January 2005
Location: United States
Online Status: Offline
Posts: 26
Posted: 05 August 2008 at 1:21pm | IP Logged Quote mosco

For the second rule I am also trying, which seems to do what I want:

RewriteRule ^(?!(?:/-|/login)).*|/ /redirect.html [I,L]

Is this the correct way of doing this?
Back to Top View mosco's Profile Search for other posts by mosco
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7598
Posted: 07 August 2008 at 7:12pm | IP Logged Quote Lexey

All these could be handled with the single rule:

# if url is /-[number]/ or /-[number]/index.html go to redirect.html
# if url doesn't:
# start with /-
# or start with /login
# or is not /
# then go to redirect.html

RewriteRule /(?:-\d+/(?:index\.html.*)?|(?!-).*|login(?:$|/.*)) /redirect.html [I,L]
Back to Top View Lexey's Profile Search for other posts by Lexey
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum