1
我正在尝试为我的路由修改RewriteRule。我正在使用测试此页面http://htaccess.mwl.be/。如何更改已使用mod_rewrite重写的URL
请求URL是:
http://myLocalhost.com/backFromPayment/1/?status=CLEARED&amount=1718.21¤cy=USD&description=U900T2351&hash=e805f58f6f96d9ebd4e0ea9da69a37c10704d482&id_sale=8938744
的.htaccess规则是:
RewriteRule !^index.php - [C]
RewriteRule (.*) index.php?$0
输出1网址是:
http://myLocalhost.com/index.php?backFromPayment/1/index.php?
此规则适用于所有的页面,但对于chunk“?status = CLEARED & ......”这个规则是不够的。
所以我评论如下规则:
#RewriteRule !^index.php - [C]
#RewriteRule (.*) index.php?$0
并且这增加了一个:
RewriteCond %{QUERY_STRING} status=(\w+)&amount=(\w+\.{1}\w*)¤cy=(\w+)&description=(\w+)&hash=(\w+)&id_sale=(\d+)
RewriteRule ^(.*)$ /index.php?$0status/%1/amount/%2/currency/%3/description/%4/hash/%5/id_sale/%6
输出2 URL是:
http://myLocalhost.com/index.php?backFromPayment/1/status/CLEARED/amount/1718.21/currency/USD/description/U900T2351/hash/e805f58f6f96d9ebd4e0ea9da69a37c10704d482/id_sale/8938744
另一种修饰是如下:
RewriteCond %{QUERY_STRING} status=(\w+)&amount=(\w+\.{1}\w*)¤cy=(\w+)&description=(\w+)&hash=(\w+)&id_sale=(\d+)
RewriteRule ^backFromPayment/1/ http://%{HTTP_HOST}/backFromPayment/1/status/%1/amount/%2/currency/%3/description/%4/hash/%5/id_sale/%6?
输出3网址是:
http://myLocalhost.com/backFromPayment/1/status/CLEARED/amount/1718.21/currency/USD/description/U900T2351/hash/e805f58f6f96d9ebd4e0ea9da69a37c10704d482/id_sale/8938744
我修改不起作用。但我注意到,当我手动修改URL(复制/粘贴输出3)时,URL起作用。
所以我必须修改的.htaccess的这一部分:
RewriteRule !^index.php - [C]
RewriteRule (.*) index.php?$0
做什么修改本节?