2013-10-24 89 views
2

我有一些問題,以建立我的網址重寫。在我的本地服務器上,使用nginx,一切都很順利。但只要我努力使其與htacces工作apache,我有點瘋了。問題與URL重寫和參數GET

我的網址正在尋找這樣的:

http://example.com/controller/action/param1/value1/param2/value2

以下是htaccess前一個案子:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteBase/
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
    RewriteCond %{REQUEST_URI} !^/(images|css|js)/ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-l 
    RewriteRule ^(.*)$ index.php?$1 [L] 
</IfModule> 

但在某些情況下,我有一些額外的參數,例如用於Facebook認證:

http://example.com/controller/action?hauth.start=Facebook&hauth.time=1382665465

這種情況下不與以前htaccess工作。 GET變量沒有任何進展。我怎麼能解決這個問題?

回答

2

使用QSA(查詢字符串追加)在規則標誌

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteBase/
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
    RewriteCond %{REQUEST_URI} !^/(images|css|js)/ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-l 
    RewriteRule ^(.*)$ index.php?$1 [L,QSA] 
</IfModule> 

QSA標誌可確保同時增加新的查詢參數保留現有的查詢字符串。