2012-06-23 29 views
0

我目前使用的htaccess使用下面,它的做工精細重寫一個查詢字符串,以它的頁面名稱...htaccess以及mod_rewrite的使用多個查詢字符串

Options +FollowSymLinks 


RewriteEngine on 
    RewriteBase/

    RewriteCond %{HTTP_HOST} !^www\. 
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

    # Rewrites urls in the form of /parent/child/ 
    # but only rewrites if the requested URL is not a file or directory 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.+)$ /index.php?page=$1 [QSA] 

我的問題是,我現在想實現原始頂部的額外querystrings。我可以成功訪問頁面/property-listing&property=12-Langworthy-Royston-Grove

但是我想能夠改寫&property=僅僅是一個斜槓,所以基本上除去額外的查詢參數,同時保持正常的重寫規則,如果沒有額外的查詢字符串參數通過。

感謝您的任何幫助,

馬特。

回答

0

嘗試前年增加這條規則:

RewriteRule ^(.+)&property=(.*)$ /index.php?page=$1/$2 [L,QSA] 

但是請注意,如果&property=是URI的一部分,這隻會工作(在這個例子中,你表示這是),因爲它是唯一的URI是重寫規則的主題,而不是查詢字符串。

相關問題