2014-06-20 87 views
0

當前URLURL重寫規則不工作

http://mywebsite.com/explore.php?location=india&search_query=about&filter[]=v 

所需的URL中使用

http://mywebsite.com/explore/india/about/v 

規則:

RewriteRule ^explore/([^/]*)/([^/]*)/([^/]*)$ /explore.php?location=$1&search_query=$2&filter[]=$3 [L] 

回答

0

你忘了指定你的話可以超過一個字符。我認爲你需要更多的東西一樣:

RewriteEngine on 
RewriteRule ^explore/([^/]*)/([^/]*)/([^/]*)$ /explore.php?location=$1&search_query=$2&filter[]=$3 [L] 

隨着

http://mywebsite.com/explore/india/about/v 

,如果你在explore.php輸出$_GET,你會得到:

array(3) { 
    ["location"]=> string(5) "india" 
    ["search_query"]=> string(5) "about" 
    ["filter"]=> array(1) { 
     [0]=> string(6) "v" 
    } 
} 

您的實際RewriteRule工作類似:

http://mywebsite.com/explore/i/a/v 

希望它有幫助

+0

這是工作時,我在地址欄中輸入所需的URL,但當前的URL沒有被重定向到所需的URL。 – amansoni211