URL rewrite help with Querystring needed

Discuss practical ways rearrange URLs using mod_rewrite.

URL rewrite help with Querystring needed

Postby mamin123 » Thu Sep 18, 2008 6:13 pm

I have below rule written which works fine with one scenario:

Code: Select all
RewriteRule ^.+-p-(.+)\.htm?$ /showproduct.asp?productid=$1


/decoupage-diva-tray-by-faber-castell-p-cfk1061.htm

Will covert to below as expected

/showproduct.asp?productid=cfk1061

but I have second scenario where i want to covert below url to as follows"

/decoupage-diva-tray-by-faber-castell-p-cfk1061.htm?src=test
/showproduct.asp?productid=cfk1061&src=test

How do I achieve both scenario with one rule if possible.

If not possible, what will be second rule I need ?

Thanks in advance for your help
mamin123
 
Posts: 2
Joined: Mon Sep 01, 2008 11:05 am
Location: USA

Postby richardk » Fri Sep 19, 2008 7:28 am

With the QSA (Query String Append) flag.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^.+-p-(.+)\.htm$ /showproduct.asp?productid=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests

cron