5, nginx 的if 语句格式

[root@centos7 nginx]# cat nginx.conf

worker_processes 2;
events {
    worker_connections 1024;
}

http {
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    sendfile            on;
    keepalive_timeout   65;
    server {
        listen 80;
        server_name  www.etiantian.org;
        index index.html index.htm;
        if ($host = "www.etiantian.org") {
		rewrite ^/(.*)$ http://bbs.etiantian.org/$1 permanent;
		}  
   }
    
    server {
        listen 80;
        server_name  bbs.etiantian.org;
        index index.html index.htm;
        location / {
        	if ($host = 'bbs.etiantian.org') {
			rewrite  ^/$    http://www.taobao.com;
			}
		}
     }
}

[root@centos7 nginx]# 

  

猜你喜欢

转载自www.cnblogs.com/k8s-pod/p/13378085.html