【发布时间】:2018-03-08 02:32:25
【问题描述】:
我有一堆像https://example.com/index.php?articles_id=XX 这样的网址,其中XX 是某个数字。我想要 将它们全部重定向到https://example.com/maps.php(忽略参数),但我使用的重定向代码都不起作用。参观时 原始 url,浏览器只是循环直到它最终超时。第二个 url 指向一个工作页面。
我第一次尝试:
RewriteRule ^articles_id=(.*)$ /maps.php [L,R=301]
然后
RewriteRule ^https://example.com/index.php?articles_id=(.*)$ /maps.php [L,R=301]
然后
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php?articles_id=\ HTTP/
RewriteRule ^index\.php?articles_id=$ https://example.com/maps.php [R=301,L]
最后
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php?articles_id=\ HTTP/
RewriteRule ^(.*)$ ./maps.php [R=301,L]
文件中还有其他重定向代码在起作用,比如这个:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ https://example.com/ [R=301,L]
有人可以指出重定向不起作用的原因吗?
【问题讨论】:
-
从示例中逐步尝试。暂时取消注释您当前的工作。