【问题标题】:301 redirect via index.php in server root not redirecting properly301 通过服务器根目录中的 index.php 重定向未正确重定向
【发布时间】:2015-02-12 07:02:20
【问题描述】:

我遇到了 301 重定向问题。

我刚刚购买了新的共享虚拟主机。然后,我将(我希望重定向的域的)名称服务器设置为新的网络主机名称服务器。

然后我通过 cPanel 将 index.php 上传到 public_html。

在 index.php 中我有以下代码:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: en.wikipedia.org/wiki/my_company_page");
?>

然后我转到域,但它没有在网络浏览器中正确重定向。

而不是被重定向到:

en.wikipedia.org/wiki/my_company_page

我被重定向到:

http://www.OriginalDomain.com/en.wikipedia.org/wiki/my_company_page

在过去的几年里,我已经多次这样做了....我查看了我拥有的另一个网站(同一家共享托管公司,相同的 301 重定向方法),它运行良好。

你们能弄清楚为什么这次它不起作用吗?

这可能是因为我刚刚切换了域名服务器,因此 DNS 没有传播(还)。

【问题讨论】:

  • 你需要使用http://前缀。

标签: http-status-code-301


【解决方案1】:

header("Location: http://en.wikipedia.org/wiki/my_company_page"); 呢?

【讨论】:

    【解决方案2】:

    我在服务器中没有任何文件。我只想通过 index.php 重定向。我以前做过很多次......但我不知道为什么这次它不起作用。

    我怀疑这是由于 DNS 仍在传播......但希望有人能证实这一点。

    【讨论】:

    • 这不是因为 DNS 仍在传播,而是因为您忘记了 http 前缀。如上所述。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-12
    • 2013-04-10
    • 2012-12-18
    • 2012-04-27
    • 1970-01-01
    • 2013-02-22
    相关资源
    最近更新 更多