我有一个删除index.php(codeigniter)的htaccess文件。我遇到Paypal问题,导致返回网址使用查询字符串,这在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
任何好主意如何做到这一点?
答案 0 :(得分:0)
在RewriteBase /
#for booking confirmed and declined
RewriteCond %{REQUEST_URI} /site/booking(confirmed|declined)/$ [NC]
RewriteCond %{QUERY_STRING} (^|&)token=([^&]+)(&|$) [NC]
#rewrite to /site/bookingdeclined/EC-56G61173NH540131H
RewriteRule ^ %{REQUEST_URI}%2 [L]
如果要更改客户端在其地址栏中看到的URL,请将最后一条规则更改为
RewriteRule ^ %{REQUEST_URI}%2 [L,R=301]