0

I'm trying to rewrite the following URL:

http://mysite.com/app/checkout/success?token=2V5W&PayerID=WBBQER

to

http://mysite.com/app/index.php?url=checkout/process/2V5W/WBBQER


This rewrite is only needed for GET request of the format (/checkout/success?token=xx&payerID=xx), where both "token" and "payerID" are fixed parameters.

I'm also including my current .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1

I've been trying countless .htaccess possibilities to no avail so your help will be greatly appreciated.

raskolnnikov
  • 37
  • 1
  • 8
  • Don't have enough time to write an answer, but the idea is that you make a RewriteCond that describes the format of parameters you want. (analyze the `%{QUERY_STRING}` variable). Then do the rewrite. This answer should be helpful: http://stackoverflow.com/questions/2703821/problem-with-rewritecond-query-string-backreference-not-dispaying-in-final-u – naivists Oct 24 '13 at 07:39

1 Answers1

4

Try this

RewriteCond %{QUERY_STRING}  ^token=([^\&]+)&PayerID=(.*)$ [NC]
RewriteRule ^app/checkout/success$ http://mysite.com/app/index.php?url=checkout/process/$1/$2 [R=301,NE,NC,L]
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166
  • Great, this works like a charm! Just had to change the '$1' and '$2' to '%1' and '%2'. By the way, the "token" variable might have dashes (-) in it. Will those be detected as well? – raskolnnikov Oct 24 '13 at 08:14
  • Yes. This will work with dashes too because the regex will match anything that is not an & character. Don't forget to upvote if you are happy with this solution :) – KodeFor.Me Oct 24 '13 at 08:28