旧网址为http://www.mhmn-test.com/dashboard.php?cat=home-construction
我的新网址为http://www.mhmn-test.com/list/home-construction
我使用过这个htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^list/(.*)/(.*)/$ search.php?cat=$1&subcat=$2 [L]
RewriteRule ^list/(.*)$ dashboard.php?cat=$1 [L]
#RewriteRule search.php?cat=$1&subcat=$2 ^list/(.*)/(.*)/$ [L]
RewriteRule dashboard.php?cat=$1 ^list/(.*)$ [L]
我只想显示新网址
答案 0 :(得分:0)
您还需要2个规则才能将旧网址重定向到新网址:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+list\.php\?cat=([^&]*)&subcat=([^\s&]+) [NC]
RewriteRule ^ list/%1/%2? [R=302,L]
RewriteRule ^list/([^/]+)/([^/]*)/?$ search.php?cat=$1&subcat=$2 [L,QSA]
RewriteCond %{THE_REQUEST} \s/+dashboard\.php\?cat=([^\s&]+) [NC]
RewriteRule ^ list/%1? [R=302,L]
RewriteRule ^list/([^/]*)/?$ dashboard.php?cat=$1 [L,QSA]