0

我怎样才能得到

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
4

1 回答 1

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]

于 2013-03-11T17:08:43.693 回答