Forum Moderators: phranque
1) Artist
http://www.example.com/r/the-rolling-stones/
loads
http://www.example.com/rewrites/artist.php?artist=the-rolling-stones
My .htaccess URL Rewrite looks like this:
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/$ rewrites/artist.php?artist=$2&%{QUERY_STRING} [L]
2) Song
http://www.example.com/r/the-rolling-stones/brown-sugar/
loads
http://www.example.com/rewrites/song.php?artist=the-rolling-stones;song=brown-sugar
Note: I'm using a semi-colon as the querystring separator b/c some of the artists or ringtones have an ampersand in the name. This is set in my .htaccess like this:
php_value arg_separator.input ";" My .htaccess URL Rewrite looks like this:
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/([.',()&a-zA-Z0-9-]{2,})/$ rewrites/song.php?artist=$2;song=$3&%{QUERY_STRING} [L]
The problem:
I'm sending traffic to the site from various ad networks, which pass in querystring values to the URLs. Some examples:
http://www.example.com/r/the-rolling-stones/?keyword=stones
http://www.example.com/r/the-rolling-stones/?keyword=mick%20jagger
I need the URL rewrite to pass the "keyword" value through to the artist.php (and similarly for the song.php process). I can't get the rewrite to work. I would want the above examples to rewrite to this:
http://www.example.com/rewrites/artist.php?artist=the-rolling-stones;keyword=stones
http://www.example.com/rewrites/artist.php?artist=the-rolling-stones;keyword=mick jagger
Any help would be greatly appreciated.
[edited by: jdMorgan at 8:36 pm (utc) on June 3, 2008]
[edit reason] Disabled "smilies" in code [/edit]
I *think* I've isolated the problem as being related to the question mark in my rewrite. I'm escaping the question mark but it doesn't seem to work.
Here's a more simplified example:
This URL:
http://www.example.com/r/the-rolling-stones/?123
should rewrite to
http://www.example.com/rewrites/artist.php?artist=the-rolling-stones;keyword=123
I've tried this rewrite with no luck (returns 404):
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/\?([0-9]+)$ rewrites/artist.php?artist=$2;gkw=$3 [L]
I can get this to work:
http://www.example.com/r/the-rolling-stones/123
successfully rewrites to
http://www.example.com/rewrites/artist.php?artist=the-rolling-stones;keyword=123
using this rewrite:
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/([0-9]+)$ rewrites/artist.php?artist=$2;gkw=$3 [L]
Does the question mark have to be escaped in a special way since it is a quantifier?
[edited by: jdMorgan at 11:13 pm (utc) on June 4, 2008]
[edit reason] Disabled graphic smilies in code. [/edit]
Search Webmaster World on "question mark" [google.com]
/r/the-rolling-stones/?123 --> /rewrites/artist.php?artist=the-rolling-stones;gkw=123
RewriteCond %{QUERY_STRING} ^([0-9]+)$
RewriteRule ^[a-z0]/([.',:()&a-zA-Z0-9\-]{2,})/$ rewrites/artist.php?artist=$1;gkw=%1 [L]
[edit] Adjusted your rewrite example to match your code [/edit]
[edited by: jdMorgan at 4:22 am (utc) on June 5, 2008]
Here are my rewrites for the Artist pages. The first handles the "gkw" value (Google Adwords keyword) in the querystring:
# gkw artist
RewriteCond %{QUERY_STRING} ^gkw=([%.',()a-zA-Z0-9-]+)$
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/$ rewrites/artist.php?artist=$2;gkw=%1 [L]
The second handles "ovkey" (Overture/Yahoo keyword) in the querystring
# ovkey artist
RewriteCond %{QUERY_STRING} ^ovraw=([%.',()a-zA-Z0-9-]+)&ovkey=([%.',()a-zA-Z0-9-]+)&([^/]*)$
RewriteRule ^([a-z0]{1})/([.',:()&a-zA-Z0-9-]{2,})/$ rewrites/artist.php?artist=$2;ovkey=%2 [L]
Thanks again!
[edited by: jdMorgan at 9:49 pm (utc) on June 5, 2008]
[edit reason] Disable graphical smilies in code. [/edit]
Jim