[UPHPU] Using mod_rewrite to Pass URLs as GET Variables
Kirk Ouimet
kirk at kirkouimet.com
Sat Apr 18 14:55:15 MDT 2009
Awesome. This worked perfectly.
Thanks Brady!
Kirk Ouimet
kirk at kirkouimet.com
-----Original Message-----
From: Brady Mitchell [mailto:mydarb at gmail.com]
Sent: Saturday, April 18, 2009 12:59 PM
To: Kirk Ouimet
Cc: uphpu at uphpu.org
Subject: Re: [UPHPU] Using mod_rewrite to Pass URLs as GET Variables
On Apr 18, 2009, at 1140AM, Kirk Ouimet wrote:
> I got it working for everything up to the query string using this
> rule:
>
> RewriteRule ^url/(.+)$ /?page=url&url=$1 [L]
You need to use the QSA flag to pass the original query string to the
new script:
RewriteRule ^url/(.+)$ /?page=url&url=$1 [L,QSA]
When I added that and did var_dump($_GET) this was the output:
array
'page' => string 'url' (length=3)
'url' => string 'http:/www.google.com/search' (length=27)
'hl' => string 'en' (length=2)
'q' => string 'test' (length=4)
'btnG' => string 'Search' (length=6)
'cts' => string '1240079299914' (length=13)
You can either piece the original query string back together using
what's in $_GET, or you could look at the $_SERVER array and use one
of the following:
'QUERY_STRING' => string
'page=url&url=http:/www.google.com/search&hl=en&q=test&btnG=Search&cts=12400
79299914&q=test&btnG=Search&cts=1240079299914'
(length=120)
'REQUEST_URI' => string
'/url/http://www.google.com/search?hl=en&q=test&btnG=Search&cts=124007929991
4&q=test&btnG=Search&cts=1240079299914'
(length=113)
HTH,
Brady
More information about the UPHPU
mailing list