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: url rewrite based on folder and product Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
schalk
Newbie
Newbie


Joined: 15 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 33
Posted: 10 August 2008 at 11:23am | IP Logged Quote schalk

I need to be able to rewrite these seo friendly urls so that they are sent to the relevant category or product handler, each within their own unique folder, using the product or category friendly name as the id used by the handler program. (Note the category has a further sub folder)

/folder1/category/friendlyname.asp to /folder1/category/category.asp?url=friendlyname.asp 

/folder1/productname.asp to folder1/product.asp?url=productname.asp

I would then duplicate the rules for each of the different folders folder1, folder2 etc etc

Please help of the rules

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


Joined: 15 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 33
Posted: 11 August 2008 at 8:10am | IP Logged Quote schalk

Further to this, I forgot to mention that the product or category name, would be deduced, by calculating the full length of the url, then subtracting the website name and folder to end up with just the product part of the url.

Is this sort of thing possible?

Back to Top View schalk's Profile Search for other posts by schalk
 
Lexey
Moderator Group
Moderator Group


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

RewriteRule (/[^/?]+/category/)([^/?.]+\.asp) $1category.asp\?url=$2 [I,L]

RewriteRule (/[^/?]+/)([^/?.]+\.asp) $1product.asp\?url=$2 [I,L]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
schalk
Newbie
Newbie


Joined: 15 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 33
Posted: 11 August 2008 at 12:29pm | IP Logged Quote schalk

Thanks Lexey, so do these rules, pick the category name?

E.g. http://www.mywebsite/folder1/category/health.asp

In this example I would want the health.asp part rewriting to real file as below

http://www.mywebsite/folder1/category/category.asp?health.asp

The reason why I ask, I saw in the isapi V3 documnetation that there is a map function that lets you map urls to id's.

Back to Top View schalk's Profile Search for other posts by schalk
 
Lexey
Moderator Group
Moderator Group


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

Yes, the first rule will perform the above rewrite.
Maps are good in a case when no generic regular expression could be written. In this case it could be easily created, so there is no need for map files usage.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
schalk
Newbie
Newbie


Joined: 15 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 33
Posted: 12 August 2008 at 12:01pm | IP Logged Quote schalk

Thanks Lexey

Final part of my jigsaw, is to allow the product redirect to occur in the same folder as the category.

I am going to apply individual rules for each of the sub folders folder1, folder2 as per below

RewriteRule (/folder1/category/)([^/?.]+\.asp) $1category.asp\?url=$2 [I,L] 

But I think the second rules may not work, unless I exclude the match if it finds a further sub folder. So I need a rule that rewrites this

http://www.mywebsite/folder1/productname.asp

So I presume I would need something like

RewriteRule (/folder1/)(?!category)(productname/)([^/?.]+\.asp) $1product.asp\?url=$2 [I,L]

 

Back to Top View schalk's Profile Search for other posts by schalk
 
Lexey
Moderator Group
Moderator Group


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

I have not got an idea of your concern.

RewriteRule (/folder1/category/)([^/?.]+\.asp) $1category.asp\?url=$2 [I,L]

will not match http://www.mywebsite/folder1/productname.asp.
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