配置第二个域名:
编辑配置文件,在原来的域名后面再加一个域名就可以访问到了。
域名重定定向意为,访问A域名时自动跳转到B域名。
if ( $host = blog.aminglinux.cc )
{
rewrite /(.*) http://www.aming.com/$1 permanent;
}
对blog.aminglinux.cc的访问会重新定向www.aming.com上
[root@CentOS-1 ~]# curl -x127.0.0.1 -I blog.aminglinux.cc/1.txt
curl: (7) Failed connect to 127.0.0.1:1080; Connection refused
[root@CentOS-1 ~]# curl -x127.0.0.1:80 -I blog.aminglinux.cc/1.txt
HTTP/1.1 301 Moved Permanently
Server: nginx/1.14.2
Date: Sat, 02 Feb 2019 15:58:22 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: http://www.aming.com/1.txt 可以看到location已经转变
取消vim中的黄色高亮: nohlsearch
状态码:200 正常访问 404不存在 304(缓存) 301(永久重定向) 302(临时重定向)
对于搜索引擎来讲,必须用301
如果是域名跳转就用301,其他的例如内部跳转就用302。