我怎样才能得到
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
我怎样才能得到
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
你可以试试这个:
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]