2012-09-21 83 views
0

友好的URL我要變換的以下網址:與mod_rewrite的

http://localhost/index.php?foo=bar&bar=foo 

分爲:

http://localhost/index/bar/foo 

換句話說,我想更換頁面擴展以正斜槓,然後遞歸改寫一個或更多的變量。

這可能嗎?

回答

0
# to redirect the browser to friendly 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?foo=([^&]+)&bar=([^&\ ]+) 
RewriteRule^/index/%1/%2? [L,R=301] 

# to internally rewrite friendly back to the proper resource 
RewriteRule ^/?index/([^/]+)/([^/]+)$ /index.php?foo=$1&bar=$2 [L,QSA]