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: Rewrite Rule Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
quarkmike
Newbie
Newbie


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 04 July 2008 at 3:37am | IP Logged Quote quarkmike

Hi there,

I try to transform this:


http://domain/Comment1/Comment2/page/01-02-03-04-05

to

http://domain/index.cfm?page=page&var1=01&var2=02&var3=03&var4=04&var5=05

and if it's possible the number of var can be change, sometimes only 1 var sometimes 2 ...

Thanks.


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


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 08 July 2008 at 5:36am | IP Logged Quote quarkmike

Anyone can help me ? Impossible to do ?
Back to Top View quarkmike's Profile Search for other posts by quarkmike
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7372
Posted: 08 July 2008 at 3:45pm | IP Logged Quote Lexey

Well, this could be done for a fixed maximum number of parameters. For example, for maximum 5 parameters the rule is:

RewriteRule /Comment1/Comment2/([^/?]+)/([^-?]*)(?:-([^-?]*)(?:-([^-?]*)(?:-([^-?]*)(?:-([^-?]*))?)?)?)? /index.cfm\?page=$1(?2&var1=$2(?3&var2=$3(?4&var3=$4(?5&var4=$5(?6&var5=$6:):):):):) [I,L]

Edited by Lexey - 08 July 2008 at 3:45pm
Back to Top View Lexey's Profile Search for other posts by Lexey
 
quarkmike
Newbie
Newbie


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 09 July 2008 at 4:09am | IP Logged Quote quarkmike

Thanks a lot Lexey it's perfect.

Mike.
Back to Top View quarkmike's Profile Search for other posts by quarkmike
 
quarkmike
Newbie
Newbie


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 09 July 2008 at 6:21am | IP Logged Quote quarkmike

Hum, now i got a problem :) when i try to insert a image like <img src="/files/images/tn100/file.jpg"> the image don't appeat because of the rule. A solution is possible for that ?

Mike.
Back to Top View quarkmike's Profile Search for other posts by quarkmike
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7372
Posted: 09 July 2008 at 7:45pm | IP Logged Quote Lexey

http://www.helicontech.com/forum/forum_posts-TID-4740.htm

Edited by Lexey - 09 July 2008 at 7:45pm
Back to Top View Lexey's Profile Search for other posts by Lexey
 
quarkmike
Newbie
Newbie


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 10 July 2008 at 9:09am | IP Logged Quote quarkmike

I Already put all of my <img src> the / but he don't care about.

When i have a <im src="/fichiers/img/details/XXXX.jpg"> the img don' t appear, when i look at the debug i can see that he take Fichiers,img,details like a variable so he don't look for a img but for a web page.

Mike.

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


Joined: 12 March 2008
Online Status: Offline
Posts: 9
Posted: 10 July 2008 at 9:15am | IP Logged Quote quarkmike

for this example the log tell me that :

PAGE = Images
V1 = details/tn100

etc ...

And because page is the condition to change page ... he try to find the images condition.

(i use page variable to include a page like this : if page  is 'rubrique' include page rubrique.cfm)


Back to Top View quarkmike's Profile Search for other posts by quarkmike
 
cleo-marc
Newbie
Newbie


Joined: 03 July 2008
Location: United Kingdom
Online Status: Offline
Posts: 14
Posted: 10 July 2008 at 10:27am | IP Logged Quote cleo-marc

Lexey wrote:
Well, this could be done for a fixed maximum number of parameters. For example, for maximum 5 parameters the rule is:

RewriteRule /Comment1/Comment2/([^/?]+)/([^-?]*)(?:-([^-?]*)(?:-([^-?]*)(?:-([^-?]*)(?:-([^-?]*))?)?)?)? /index.cfm\?page=$1(?2&var1=$2(?3&var2=$3(?4&var3=$4(?5&var4=$5(?6&var5=$6:):):):):) [I,L]

For the benefit of regex numpties like me, can you explain what you're doing, there?  I'm having trouble seeing how that works!

 



__________________
--
Marc
Back to Top View cleo-marc's Profile Search for other posts by cleo-marc Visit cleo-marc's Homepage
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7372
Posted: 10 July 2008 at 5:08pm | IP Logged Quote Lexey

Quote:

When i have a <im src="/fichiers/img/details/XXXX.jpg"> the img don' t appear, when i look at the debug i can see that he take Fichiers,img,details like a variable so he don't look for a img but for a web page.


So, you need a rule to exclude images. For example, like that:

RewriteRule [^?]*\.(?:jpg|gif)(?:\?.*)? $0 [I,L]

Quote:

For the benefit of regex numpties like me, can you explain what you're doing, there? I'm having trouble seeing how that works!


This rule captures optional variables into submatches $2, $3, etc Then they are being checked for non-emptiness and added to an output.
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