原来我的网站重定向只是在.htaccess文件里这么写:
RewriteEngine on
RewriteCond %{http_host} ^sijitao.net [NC]
RewriteRule ^(.*)$ http://blog.nbqykj.cn/?p=$1 [L,R=301]
因为自己用的linux系统的vps主机,而且安装的是lnmp,所以找到如下新的方法试试:
打开/usr/local/nginx/conf/vhost下相应的.conf文件,在代码的最后面加上如下代码:
打开/usr/local/nginx/conf/vhost下相应的.conf文件,在代码的最后面加上如下代码:
server {
server_name sijitao.net;
rewrite ^(.*) http://blog.nbqykj.cn/?p=$1 permanent;
}
server_name sijitao.net;
rewrite ^(.*) http://blog.nbqykj.cn/?p=$1 permanent;
}
最后得到的完整代码如下所示:
server
{
listen 80;
server_name blog.nbhao.org;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/blog.nbhao.org; include none.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} access_log off;
}
server {
server_name sijitao.net;
rewrite ^(.*) http://blog.nbqykj.cn/?p=$1 permanent;
}
{
listen 80;
server_name blog.nbhao.org;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/blog.nbhao.org; include none.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} access_log off;
}
server {
server_name sijitao.net;
rewrite ^(.*) http://blog.nbqykj.cn/?p=$1 permanent;
}
修改保存后记得重启lnmp,/root/lnmp restart 。这样用户打开sijitao.net时候也会转到blog.nbhao.org去了。不过sijitao.net虽然用了301重定向,但还是要做A记录解析的。
评论列表(0条)