mod_rewrite没有传递查询字符串

时间:2013-11-16 13:36:17

标签: php apache .htaccess mod-rewrite rewrite

我的mod_rewrite有问题。

这是我的.htaccess文件:

#REWRITE
RewriteEngine On    #Turn on the RewriteEngine
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^admin/(.*)/?$ admin.php?kappa=$1 [NC,L,QSA] # Handle Admin Panel
RewriteRule ^buypoint/([0-9]+)/?$ baltopoints.php?sid=$1 [NC,L] # Handle bit->Point requests
RewriteRule ^history/([0-9]+)?/?$ history.php?page=$1 [NC,L] # Handle Transaction requests
RewriteRule ^topupstatus/(.*)/?$ topupsta.php?ec=$1 [NC,L] # Handle index
RewriteRule ^refresh/(.*)?$ refresh.php [NC,L] # Handle Refresh requests
RewriteRule ^refill/(.*)?$ topup.php [NC,L] # Refill
RewriteRule ^topup/(.*)?$ topup.php [NC,L] # Refill
RewriteRule ^ucp/?(.*)?$ main.php [NC,L] # Handle index
RewriteRule ^logout/?(.*)?$ logout.php [NC,L] # Handle Logout

重写仅适用于规则:
^ buypoint /([0-9] +)/?$ baltopoints.php?sid = $ 1 [NC,L] 规则 (buypoint / 1 将重写为 baltopoints.php?sid = 1)
否则,仅适用于第一个斜线(admin / viewbtx 将重写为 admin.php [没有查询字符串]

有人可以帮我解决这个问题吗?

3 个答案:

答案 0 :(得分:0)

规则将regexp与URi less 查询字符串相匹配。模式中的?使前一个原子可选。这是std regexp语法,因此^a.php?e=$1$将匹配a.phe=23。您使用RewriteCond之前的RewriteRule语句解析查询字符串,例如:

RewriteCond %{QUERY_STRING}  ^ec=(\d+)

现在%1索引号可用于规则替换字符串。阅读Apache Module mod_rewrite documentation中的示例。

答案 1 :(得分:0)

我通过将admin.php重命名为admincp.php并使用
RewriteRule ^admin/(.*)$ admincp.php?do=$1 [NC,L,QSA]
规则代替相关的规则来解决这个问题,所以我认为这是apache bug什么

答案 2 :(得分:0)

我给另一个问题的答案相同,它可能对你有用

How to htaccess redirect this long URL?

相关问题