Dynamic URL rewrites

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Dynamic URL rewrites

27 Apr 2013, 17:28

I have rules in place already that convert DYNAMIC URLs like productdetails.asp?subcatagoryid=123&productid=22

to SEO compatible urls like C123-CatName-P22-Productname.asp

But I have made some big changes in the database recently and need to redirect certain specific urls that no longer exist in the database and now just give errors when you visit them:

for example:
ProductDetails.asp?subcatagoryid=244&ProductID=1177

I would like to redirect everything that has subcatagoryid=244 to newurl.asp regardless of anything else that comes after in the url.


How would I create this rule and should I place it above the general rules that rewrite the other URLs?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Dynamic URL rewrites

29 Apr 2013, 00:48

Hello,

You would put this rule at the top of your config file and use the following syntax:

Code: Select all
[ISAPI_Rewrite]

RewriteRule ProductDetails\.asp?subcatagoryid=244.* http\://www\.site\.com/newurl\.asp [I,RP]


Regards
Andrew

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: Dynamic URL rewrites

29 Apr 2013, 07:28

Hi there, thank you for your reply. However that didnt work.
It didnt do anything for some reason.

Here is my httpd.ini file with the working rules that are already in it:

Code: Select all
[ISAPI_Rewrite]

#Images & Css
RewriteRule .*\.(?:css|jpg|png|js|gif) $0


#project rules

RewriteRule /P(\d+).*\-C(\d+)\.asp /productdetails.asp\?ProductID=$1&SubCatagoryID=$2 [I,L] 
RewriteRule /P(\d+)-pg(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1 [I,L]
RewriteRule /P(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1 [I,L]


#category rules
RewriteRule /d(\d+)-pg(\d+)(.*?)/?        /Products.asp\?SubCatagoryID=$1 [I,RP,L]
RewriteRule /d(\d+)(.*?)/?       /Products.asp\?SubCatagoryID=$1 [I,L]

#testimonial rules

 
RewriteRule /T(\d+)-pg(\d+)(.*)\.asp    /Testimonialdetails.asp\?TestimonialID=$1 [I,L]
RewriteRule /T(\d+)(.*)\.asp    /Testimonialdetails.asp\?TestimonialID=$1 [I,L]


User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Dynamic URL rewrites

29 Apr 2013, 10:14

I'm sorry, try:

Code: Select all
RewriteRule /ProductDetails\.asp\?subcatagoryid=244.* /newurl\.asp [I,RP]


Regards
Andrew

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: Dynamic URL rewrites

29 Apr 2013, 12:31

That did it, great thanks for your help...

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 2 guests