一、Windows 主机 或者 Linux 主机,修改apache的配置文件.htaccess
打开WordPress 根目录下 .htaccess 文件修改成下面样子
# BEGIN WordPress
Options +FollowSymLinks
RewriteEngine on
rewritecond %{http_host} ^www.old.com [nc]
rewriterule ^(.*)$ http://www.new.com/$1 [L,R=301]
# END WordPress
提示:www.old.com 替换为你的老域名,www.new.com 替换为你的新域名
二、Windows 主机,可以用 php 跳转(方法来自互联网了)
修改 wordpress 根目录下的 wp-blog-header.php,并在文件开头
if (strtolower($_SERVER['SERVER_NAME'])!='abc.com')
{
$URIRedirect=$_SERVER['REQUEST_URI'];
if(strtolower($URIRedirect)=="/index.php")
{
$URIRedirect="/";
}
header('HTTP/1.1 301 Moved Permanently');
header('Location:http://abc.com'.$URIRedirect);
exit();
}
提示:把里面的两个 abc.com修改成你的新域名