添加301重定向到php文件

时间:2011-01-28 10:53:44

标签: redirect

我需要在我的网站上添加一些链接,我使用这个代码使用名为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。 提前致谢

1 个答案:

答案 0 :(得分:0)

它适用于我的电脑

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