如何将URI从example.com/search/.../?folder=something
重定向到example.com/something/search/.../
?
是否有htaccess规则?
答案 0 :(得分:2)
您可以尝试将此规则作为第一条规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+([^?]+)\?folder=([^\s&]+) [NC]
RewriteRule ^ /%2/%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.+?)/?$ /$2/?folder=$1 [QSA,L]