将… /?token = xx-xxx转换成… / xx-xxx

我有一个移除index.php(codeigniter)的htaccess文件。 我有一个问题与贝宝,导致返回的url是使用查询string,这是在codeigniter麻烦。

这是我的htaccess文件:

RewriteEngine on RewriteBase / # Hide the application and system directories by redirecting the request to index.php RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] 

我想重写下面的例子url-s:

 http://.../site/bookingconfirmed/?token=EC-56G61173NH540131H 

 http://.../site/bookingconfirmed/EC-56G61173NH540131H 

 http://.../site/bookingdeclined/?token=EC-56G61173NH540131H 

 http//.../site/bookingdeclined/EC-56G61173NH540131H 

任何好的想法如何做到这一点?

像这样的东西:

 RewriteCond %{QUERY_STRING} token=([^&]+) [NC] RewriteRule ^(site/booking.*)/?$ $1/%1? [L] 

这将确保后面的斜杠也到位,所以请求/site/bookingconfirmed?token=EC-56G61173NH540131H也可以。 它抛出查询string – 我假设没有其他东西你需要保留?

像这样的东西..非常未经testing

 RewriteEngine on RewriteBase / # Hide the application and system directories by redirecting the request to index.php RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteRule ^site/(bookingconfirmed|bookingdeclined)/\?token\=(.*)$ /site/$1/$2 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]