我想转换以下网址:
http://localhost/index.php?foo=bar&bar=foo
分为:
http://localhost/index/bar/foo
换句话说,我想用正斜杠替换页面扩展名,然后递归重写一个或多个变量。
这可能吗?
答案 0 :(得分: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]