0

我有一个格式如下的 URL:

http://domain.com/checkout/nonce/701fe0f652/order/108/?token=EC-0DS37792JX3680821

我尝试使用 .htaccess 将其转换为干净的 URL:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?token=(.*)$ /index.php/$1/token/$2/ [R]

RewriteRule 不知何故不起作用。我已经使用http://jakarta.apache.org/regexp/applet.html 对其进行了测试,并得到了完全匹配的结果。

我正在使用 CodeIgniter,并且已经测试直接放置干净的 URL (http://domain.com/checkout/nonce/701fe0f652/order/108/token/EC-0DS37792JX3680821) 没有问题。

有人可以帮助我吗?

谢谢你。

最好的祝福。

4

1 回答 1

0

我已经找到了答案

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^token=([a-zA-Z0-9\-]+)
RewriteRule ^([a-z0-9\/\-.]+)$ $1token/%1? [R=301,L]
于 2010-10-15T03:24:21.543 回答