Transform URL with text in querystring

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 09 Apr 2014, 18:15

Transform URL with text in querystring

09 Apr 2014, 18:24

Hi,
I'm sorry, probably this is a rookie question but I spent the entire day trying to make this work and all the examples I found just doesn't work.
I need to transform something like
www.mysite.com/product.asp?prodID=2323& ... of+product
into
www.mysite.com/2323/the-name-of-product.html

Is it possible somehow?

Thanks for help in advance.

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

Re: Transform URL with text in querystring

09 Apr 2014, 21:12

Hello,

It is. There're quite a lot of things like that here. You need:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^prodID=(\d+)&prodName=([^&]+)$ [NC]
RewriteRule ^product\.asp$ /%1/%2? [NC,R=301,L]


Regards

User avatar
Posts: 3
Joined: 09 Apr 2014, 18:15

Re: Transform URL with text in querystring

10 Apr 2014, 09:02

Hi Andrew,

Thank you for your help.

I did find a lot of examples out there but I just couldn't get it running properly,

The solution you gave really rewrites the url but it returns the 404 error... the product.asp file is on the server and if you call it with no querystring, it will open normaly. Should I make any changes on the server side?

Thank you again
Adré

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

Re: Transform URL with text in querystring

10 Apr 2014, 12:16

Well, you asked for redirect. Here's a second part that will make the pretty URL work:

Code: Select all
RewriteRule ^(\d+)/([^/]+)$ /product.asp?prodID=$1&prodName=$2 [NC,L]


Regards

User avatar
Posts: 3
Joined: 09 Apr 2014, 18:15

Re: Transform URL with text in querystring

10 Apr 2014, 15:07

It worked like a charm. Thank you so much... I will study more the documentation and regular expretions to do new tricks with url rewriting.

Thank you very much

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests