2011-03-02 61 views
0

我已經嘗試過,並試圖通過我的htaccess知識不是很好,我找不到任何適合我的需求(但後來我不知道我在尋找什麼對於)。簡單的htaccess國防部重寫與可能的查詢字符串

有效,我的問題是雙重的:

我想轉換:http://subdomain.domain.com/hello
要:http://subdomain.domain.com/index.php?string=hello

但偶爾也有可能是一個查詢字符串,以及如此...
來源:http://subdomain.domain.com/hello?query=true
要:http://subdomain.domain.com/index.php?string=hello&query=true

到目前爲止,我已經管理了第一個:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} -f [NC,OR] 
RewriteCond %{REQUEST_FILENAME} -d [NC] 
RewriteRule .* - [L] 
RewriteRule ^([^/\.]+)/?$ client.php?user=$1&$2 [L] 

請記住,第二個是潛在的:)謝謝!

回答

1

你只需要設置QSA flag的最後一條規則:

RewriteRule ^([^/\.]+)/?$ client.php?user=$1 [L,QSA] 

那麼原始請求的查詢會自動附加到新的一個。

+0

嗯......它總是最簡單的解決方案!謝謝! – Jordan 2011-03-03 00:18:12