我怎样才能获得
http://www.example.com/aaa/bbb/ccc
到
http://www.example.com/index.php?cat=ccc
也希望它适用于像
这样的情况http://www.example.com/aaa
http://www.example.com/aaa/
将是
http://www.example.com/index.php?cat=aaa
答案 0 :(得分:1)
你可以试试这个:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} .*/([^/]+)/? [NC]
RewriteCond %{REQUEST_URI} !index\.php [NC]
RewriteRule .* /index.php?cat=%1 [L,NC,QSA]
静默地映射:
http://www.example.com/any/number/of/folders/LastFolder
要:
http://www.example.com/index.php?cat=LastFolder
对于永久性和可见的重定向,请将[L,NC,QSA]
替换为[R=301,L,NC,QSA]