在nginx中可以对域名进行跳转如:所有对www.aaa.com的访问都redirect到www.bbb.com
server
{
listen 80;
server_name www.bbb.com;
index index.htm index.php;
root /export/home/www
if ($host = "www.aaa.com"){
rewrite ^/(.*)$ http://www.bbb.com/$1 permanent;
}
}
符号解释:
^ 匹配字符串的开始
/ 匹配域名的分隔符
. 匹配除换行符以外的任意字符
* 重复零次或更多次
(.*) 匹配任意字符
.* 匹配任意文本
$ 匹配字符串的结束
server
{
listen 80;
server_name www.bbb.com;
index index.htm index.php;
root /export/home/www
if ($host = "www.aaa.com"){
rewrite ^/(.*)$ http://www.bbb.com/$1 permanent;
}
}
符号解释:
^ 匹配字符串的开始
/ 匹配域名的分隔符
. 匹配除换行符以外的任意字符
* 重复零次或更多次
(.*) 匹配任意字符
.* 匹配任意文本
$ 匹配字符串的结束
转载于:https://blog.51cto.com/kernal/1540607