htaccess重写GET请求到另一个GET请求

时间:2013-10-24 07:34:49

标签: regex .htaccess

我正在尝试重写以下网址:

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

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


只有格式的GET请求(/ checkout / success?token = xx& payerID = xx)才需要重写,其中“令牌”“payerID”都是固定参数。

我还包括我当前的.htaccess:

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

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

我一直在尝试无数的.htaccess可能无济于事,所以我们非常感谢您的帮助。

1 个答案:

答案 0 :(得分:4)

试试这个

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]