【问题标题】:simple .htaccess 301 redirect multiple pages简单的 .htaccess 301 重定向多个页面
【发布时间】:2011-12-30 20:34:50
【问题描述】:

所以我的 .htaccess 文件看起来像这样

RewriteBase /
Redirect 301 /page.html http://www.yoursite.com/newpage.html
Redirect 301 /page2.html http://www.yoursite.com/newpage.html

它不会重定向我的 page.html

如果我离开它

RewriteBase /
Redirect 301 / http://www.yoursite.com/newpage.html

它可以工作,并重定向我所有的网站。现在为什么不工作,相信我,我在 .htaccess 文件附近有 page.html,令人沮丧的是我有 10 .html 之类的东西要重定向,而不是更多...... :(

谁能帮帮我?

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect http-status-code-301


    【解决方案1】:

    要获得等效结果,您可以在任何其他规则之前将其添加到您的 .haccess 文件中。

    RewriteEngine On
    RewriteBase /
    
    #redirect page or page2 .html
    RewriteRule ^page(|2)\.html$ http://www.yoursite.com/newpage.html [NC,R=301,L]
    

    【讨论】:

    • 好的,谢谢,这项工作,但我不想要正则表达式,只需要在 page2.html > newpath thepage1234.html > newpath 下的第一行
    猜你喜欢
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多