开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜