nginx 根據域名判斷入口文件

#根據域名改變入口文件
location / {
		set $enter_file "index";
		if($host = "s.work.test.com"){
			set $enter_file "sso";
		}
		
		if (!-e $request_filename) {
            set $enter_file "${enter_file}1";
        }
		
		#當請求地址爲存在的目錄時 依然走rewrite,主要是針對訪問根目錄默認請求 index.php 的狀況
		if (-d $request_filename) {
            set $enter_file "${enter_file}1";
        }
        
		if($enter_file = "index1"){
			rewrite  ^(.*)$  /index.php?s=$1  last;
            break;
		}
		if($enter_file = "sso1"){
			rewrite  ^(.*)$  /sso.php?s=$1  last;
            break;
		}
        index  index.html index.htm index.php;
    }
相關文章
相關標籤/搜索