How to make .htaccess nested redirect?
How to make .htaccess开发者_开发知识库 nested redirect?
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^$ %{REQUEST_URI}%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ?id=$1 [L,QSA]
It does redirect from /?id=url
to /url
, but does not redirect /1/2/3/?id=url
to /1/2/3/url
.
At the second line: ^$
matches an empty string, so only the root (like /?id=X
) is redirected. You have to add .*
to match all URIs:
RewriteRule ^.*$ %{REQUEST_URI}%1? [R=301,L]
精彩评论