带参数的 URL 重定向规则如何写

2015-09-29 10:20:57 +08:00
 RihcardLu

原始:
http://www.example.com/sub-dir/index.php?id=1

定向后:
http://www.example.com/path-to-new-location/

网上查找到的可以这么写,但是实际测试无效

RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]

参考:Common .htaccess Redirects

3013 次点击
所在节点    Apache
1 条回复
oott123
2015-09-29 13:07:41 +08:00
RewriteEngine on
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/?%{QUERY_STRING} [L,R=301]

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/224438

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX