htaccess多个网址到一个页面重定向无法正常工作

时间:2018-03-06 23:52:25

标签: .htaccess redirect

我有一堆网址如https://example.com/index.php?articles_id=XX,其中XX是一些数字。我想要 将所有这些重定向到https://example.com/maps.php(忽略参数),但我使用的重定向代码都没有。访问时 原始网址,浏览器只是循环,直到它最终超时。第二个网址是工作页面。

我第一次尝试:

    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]        

有人可以指出重定向不起作用的原因吗?

1 个答案:

答案 0 :(得分:0)

原来这是防止重定向的文件中的代码。