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: two files - same rule - can it be done? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ozbiz
Newbie
Newbie


Joined: 31 March 2003
Location: Australia
Online Status: Offline
Posts: 24
Posted: 23 July 2008 at 6:02am | IP Logged Quote ozbiz

Lexey, Yaroslav, Thank you guys - we have been using three of your licences since 2003 - you should get an award for the best software and best support on the internet. :)

I have this problem. (On this server we have V2.x but happy to upgrade to V3.x if it solves this issue).

We have two identical rules but we want the second rule to run if there is no match for the first rule.

RewriteRule ([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /fileone.asp\?one=$1\&two=$2\&three=$3 [I,O]

/variableone/two-three.htm

RewriteRule ([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /filetwo.asp\?one=$1\&two=$2\&three=$3 [I,O]

Ideally we would like the output for the second rule to be the same /variableone/two-three.htm if there is no match for variableone from the first rule. There is a reason why we have variableone coming from the same table for both files.

================

This works but...


RewriteRule /anynameone/([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /fileone.asp\?one=$1\&two=$2\&three=$3 [I,O]

/anynameone/variableone/two-three.htm

RewriteRule /anynametwo/([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /filetwo.asp\?one=$1\&two=$2\&three=$3 [I,O]

/anynametwo/variableone/two-three.htm

The second solution works but... Is there a way that we can do this without prepending the extra folder?

Best regards,
Jim
Back to Top View ozbiz's Profile Search for other posts by ozbiz Visit ozbiz's Homepage
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7598
Posted: 28 July 2008 at 4:31pm | IP Logged Quote Lexey

Quote:

We have two identical rules but we want the second rule to run if there is no match for the first rule.


And how the 2nd rule could match if the 1st rule does not match with the same pattern?
Back to Top View Lexey's Profile Search for other posts by Lexey
 
ozbiz
Newbie
Newbie


Joined: 31 March 2003
Location: Australia
Online Status: Offline
Posts: 24
Posted: 10 August 2008 at 3:00am | IP Logged Quote ozbiz

Lexey wrote:
Quote:

We have two identical rules but we want the second rule to run if there is no match for the first rule.


And how the 2nd rule could match if the 1st rule does not match with the same pattern?


Lexey, I apologise for being away so long.

This was solved for me but also my description of the problem should have been better.

We needed separate files to run depending on the row returned from one of our tables.

This is the rule which did not work without prepending an extra folder which matched the filename(from below):

RewriteRule /anynameone/([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /fileone.asp\?one=$1\&two=$2\&three=$3 [I,O]

This is the rule we were trying to make work(from below):

RewriteRule ([a-z_]+)/([a-z_]+)(?:-([a-z_]*))?\.htm /fileone.asp\?one=$1\&two=$2\&three=$3 [I,O]

This was the rule which provided the solution we were looking for:

RewriteRule ^/([a-z_]+)/([a-z_]+)(?:_([\d]+))?\.htm$ /file$2.asp\?one=$1\&three=$3 [I,O]

It uses a different file for display depending on the classification in the second variable.

Thank you for looking at this, Lexey - your help is invaluable. For me, regex is too easy to read and too hard to write.

Jim
Back to Top View ozbiz's Profile Search for other posts by ozbiz Visit ozbiz's Homepage
 

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