Transform URL with text in querystring
5 posts
• Page 1 of 1
- andresites
- Posts: 3
- Joined: 09 Apr 2014, 18:15
Transform URL with text in querystring
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Transform URL with text in querystring
Hello,
It is. There're quite a lot of things like that here. You need:
Regards
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
- andresites
- Posts: 3
- Joined: 09 Apr 2014, 18:15
Re: Transform URL with text in querystring
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é
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é
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Transform URL with text in querystring
Well, you asked for redirect. Here's a second part that will make the pretty URL work:
Regards
- Code: Select all
RewriteRule ^(\d+)/([^/]+)$ /product.asp?prodID=$1&prodName=$2 [NC,L]
Regards
- andresites
- Posts: 3
- Joined: 09 Apr 2014, 18:15
Re: Transform URL with text in querystring
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
Thank you very much
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests