Forum Moderators: phranque

Message Too Old, No Replies

Passing more vars thru the URL

         

epohcj

6:20 pm on Aug 16, 2008 (gmt 0)

10+ Year Member



i have this

RewriteEngine On
RewriteBase /
RewriteRule ^artiste/([^&]+)/albums/([^&]+)\.htm$ /template_music.php?artiste=$1&album=$2 [L]

and it works fine, but i recently discovered that i can't pass more var thru the url

eg. http://example.com/artiste/var1/albums/var2.htm (the is the rewritten URL)

but when i pass more vars in the url, php doesn't catch it.
eg. http://example.com/artiste/var1/albums/var2.htm?com_p=2
php will not catch $_GET['com_p']

how do rewrite the url to accommodate more var after the url is rewritten?

[edited by: jdMorgan at 10:38 pm (utc) on Aug. 16, 2008]
[edit reason] example.com [/edit]

jdMorgan

10:38 pm on Aug 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should review the mod_rewrite documentation at Apache.org. Your regex patterns are incorrect, and this makes your rule-processing inefficient.

To pass query string variables through a rewrite which replaces the query string as yours does, use the [QSA] flag:


RewriteRule ^artiste/[b]([^/]+)[/b]/albums/[b]([^./]+)[/b]\.htm$ /template_music.php?artiste=$1&album=$2 [b][QSA,L][/b]

Jim

epohcj

10:49 pm on Aug 16, 2008 (gmt 0)

10+ Year Member



Thanks for the quick reply. i just finished reading about QSA on a diff. site and it worked. I was about to put a close to it before i saw ur reply.
Thanks your help.