【问题标题】:Various htaccess redirect methods and why?各种 htaccess 重定向方法,为什么?
【发布时间】:2011-08-01 20:04:34
【问题描述】:

我有一个过时的 url (mydomain.com/page.html),它自然会返回 404 错误。我想实现一个永久的 301 重定向回到我在 mydomain.com 的主页。 (具有手动编辑 htaccess 文件权限的 Apache/Linux 服务器)

我希望符合 Google 的要求,即使用 301 重定向旧页面。

三种方法有效,但哪种方法最好,为什么?利弊,如果有的话?

1- 这是 cPanel 自动写入的内容(看起来有点矫枉过正)...

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^page\.html$ "http\:\/\/www\.mydomain\.com" [R=301,L]

2- 这是我过去使用的...

Redirect permanent /page.html http://www.mydomain.com

3- 我想知道这是否最好......

Redirect 301 /page.html http://www.mydomain.com

感谢您的意见!

【问题讨论】:

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


    【解决方案1】:

    解决方案 #1 使用 mod_rewrite 并且会更慢。 #2 和 #3 之间没有区别 - 都使用 mod_alias 并且应该比 #1 快。

    【讨论】:

    • 从外部的角度来看,就像谷歌一样,它们看起来都一样吗?只是一个 301 重定向,对吧?谢谢!
    • @Sparky672 是的,所有 3 个看起来都一样!
    猜你喜欢
    • 1970-01-01
    • 2017-01-14
    • 2012-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-11-30
    • 2012-03-25
    • 1970-01-01
    • 2013-01-28
    相关资源
    最近更新 更多