Fluidbyte
Fluidbyte

Reputation: 5210

Grabbing Querystrings while using ModRewrite with PHP

I'm using URL rewriting through .htaccess on my site. Then I submit through PayPal's ExpressPay and get something like the following returned:

http://mydomian.com/cart/success?token=EC-123456789&PayerID=123456789

The /cart and /success are great, but is there an easy way to grab the "token" an "PayerID" variables?

Here's the .htaccess I'm working with:

RewriteRule ^([^/\.]+)/?$ index.php?load=$1
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?load=$1&query=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?load=$1&query=$2&query2=$3 [L]

Upvotes: 0

Views: 73

Answers (3)

Jon Lin
Jon Lin

Reputation: 143896

Add a [QSA] to each of your rules, and change your third rule to have these flags: [L,QSA]. This will make it so the query string you get back from PayPal will be appended and you'll be able to access them from index.php.

Upvotes: 2

somedev
somedev

Reputation: 1053

See: URL Rewrite - Query String

Or just have mydomain.com/cart/success grab $_GET['token']

Upvotes: 0

Waygood
Waygood

Reputation: 2693

you can use {QUERY_STRING} as the condition http://www.simonecarletti.com/blog/2009/01/apache-rewriterule-and-query-string/

Upvotes: 0

Related Questions