homepage Welcome to WebmasterWorld Guest from 54.211.95.201
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_rewrite querystring param
Langers




msg:1516185
 10:09 am on Mar 29, 2006 (gmt 0)

Hi,

I am trying to convert the following:

www.widgets.com/category/sub/details.asp?prodid=1

to

www.widgets.com/product.php?product_id=1

but I am having trouble replacing the querystring parameter prodid with product_id

I tried the following but it doesn't work:

Options +FollowSymLinks +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^detail.asp\?prodid=$ /product.php?product_id=$1 [QSA]
</IfModule>

Any suggestions?

 

jdMorgan




msg:1516186
 1:35 pm on Mar 29, 2006 (gmt 0)

Query strings are not part of a URL. Rather, they are data *attached* to a URL to be passed to the resource *at* that URL.

Therefore, query strings are handled separately in Apache:

RewriteCond %{QUERY_STRING} ^prodid=([^&]+)
RewriteRule ^detail\.asp$ /product.php?product_id=%1 [L]

Jim

Langers




msg:1516187
 2:58 pm on Mar 29, 2006 (gmt 0)

Will give it a try. Thanks Jim.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved