【问题标题】:Adding 301 redirect to a php file将 301 重定向添加到 php 文件
【发布时间】:2011-01-28 19:23:34
【问题描述】:

我需要向我的网站添加一些链接,这些链接是我使用名为 redirect.php 的文件重定向的,代码如下:

<? header("HTTP/1.1 301 Moved Permanently");
$linkid = $_GET['linkid'];
if ($linkid == "1234") {$link = "http://advertiserlink.co.uk/";}
header("Location: $link");
exit();
?>  

我想问一下,从 301 重定向的角度来看,这是否正确,Google 将找不到我将在我的文本中放置的链接:例如 http://mysite.co.uk/redirect.php?linkID=1234。我还禁止在我的 robots.txt 中使用 redirect.php。 提前致谢

【问题讨论】:

    标签: redirect


    【解决方案1】:

    它可以在我的电脑上运行

    <?php
        $link = ($_GET['link'] == '1234) ? 'http://my1234.example.com/' : 'http://example.com/';
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: ' . $link);
        exit();
    ?>
    

    【讨论】:

    猜你喜欢
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    相关资源
    最近更新 更多