【发布时间】:2013-02-28 17:17:16
【问题描述】:
我要迁移到一个新域名,我需要将所有传入链接重定向到新域名。所有页面都在两个网站上。
(例如:www.oldsite.com/services.php 和 www.exemple.com/services.php 都是活动的并且相同。)
我想知道我的代码是否对 SEO 友好而不会弄乱 .htaccess 文件。
<?php
$referer = $_SERVER['SERVER_NAME'];
$domain = "www.exemple.ca";
$uri = $_SERVER['REQUEST_URI'];
if(strpos($referer,$domain) === false) {
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://www.exemple.ca$uri" );
exit(0);
} ?>
【问题讨论】:
-
通过 htaccess 来做会容易得多(两行)