2012-07-25 61 views
0

以下重写规则正在使用的.htaccess一个简单的PHP网站:现代重写丢失查询参数

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /test/ 
RewriteRule ^index\.php$ - [L] 
RewriteRule ^([a-zA-Z-]+)/?$ /test/index.php?m=$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /test/index.php [L] 
</IfModule> 

以下网址的正常工作:

domain.com/test/index.php?m=profile 
domain.com/test/profile 
domain.com/test/profile/ 

然而,更多的查询参数丢失与改写:

domain.com/test/index.php?m=profile&id=2000 ==> works 
domain.com/test/profile?id=2000 ==> does not work 
domain.com/test/profile?id=2000 ==> does not work 

任何帮助表示赞赏。

回答

0

改变这一行:

RewriteRule ^([a-zA-Z-]+)/?$ /test/index.php?m=$1 [L] 

到包括QSA标志:

RewriteRule ^([a-zA-Z-]+)/?$ /test/index.php?m=$1 [L,QSA] 

告诉阿帕奇追加现有的查询字符串到新的(m=$1)。

+0

完美的作品。谢谢! – 2012-07-25 20:40:26

+0

@ rb-sfs您应该点击左边的“复选标记”,以便您的问题被标记为已回答 – 2012-07-25 20:57:52