2014-05-20 104 views
0

我有這個網址:阿帕奇重寫兩個PHP變量,並刪除PHP擴展

http://www.website.co.uk/search.php?search=test&cat=catname 

我想的是:

http://www.website.co.uk/search/test/catname 

我曾嘗試本作的變量:

Options +FollowSymLinks 
RewriteRule ^page/([^/]+)/?$ search.php?search=$1 

這個隱藏php的擴展名:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC] 
RewriteRule^%1 [R=301,L] 

,它似乎沒有做任何事情

+1

而事實上,'^頁/'不匹配'搜索/'真的做驚喜嗎? – CBroe

回答

0

可以在根的.htaccess使用:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 

RewriteCond %{THE_REQUEST} \s/+search\.php\?search=([^\s&]+)&cat=([^\s&]+) [NC] 
RewriteRule^/search/%1/%2? [R=302,L] 

RewriteRule ^search/([^/.]+)/([^/.]+)/?$ /search.php?search=$1&cat=$2 [L,QSA,NC] 

RewriteRule ^page/([^/]+)/?$ /search.php?search=$1 [L,QSA,NC]