2012-07-25 60 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