Nginx域名重定向
2018-01-04 10:11
134 查看
配置多个域名权重变了。比如第一个是主域名,其他的跳转到主域名。
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
更改test.com.conf
server
{
listen 80;
server_name test.com test1.com test2.com;
index index.html index.htm index.php;
root /data/wwwroot/test.com;
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
}
server_name后面支持写多个域名,这里要和httpd的做一个对比
permanent为永久重定向,状态码为301,如果写redirect则为302
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
更改test.com.conf
server
{
listen 80;
server_name test.com test1.com test2.com;
index index.html index.htm index.php;
root /data/wwwroot/test.com;
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
}
server_name后面支持写多个域名,这里要和httpd的做一个对比
permanent为永久重定向,状态码为301,如果写redirect则为302
相关文章推荐
- 运维小记-域名多次重定向导致报警
- nginx子目录301重定向到其他域名URL
- 域名重定向的快速实现,解决80端口被屏蔽等
- apache重定向
- 域名从www跳转到非www,Apache和Nginx2种解决方式
- Nginx用户认证与域名重定向
- nginx用户认证
- nginx默认虚拟主机
- nginx安装
- 整合之前的一些学习记录1(nginx和apache的部署)
- 自动放行nginx后台访问ip
- Nginx学习之配置RTMP模块搭建推流服务
- nginx gzip配置参数解读
- LNMP架构(三)之Nginx访问日志,切割,静态文件不记录日志
- CentOs7.3 编译安装 Nginx 1.9.9
- Ubuntu 17.04 编译安装 Nginx 1.9.9
- lnmp之nginx安装
- nginx默认虚拟主机
- nginx配置用户认证
- nginx域名跳转