Nginx Location指令URI匹配規則詳解


server {
    listen 80;
    server_name ss.test *.ss.test;
    root "D:/Project/PHP/admin-h5/dist/";
	set $php_root "D:/Project/PHP/admin/src/public/";
	set $pic_root "D:/Project/PHP/admin/src/storage/app/";
    
    index index.html index.htm index.php;
 
    location / {
        expires -1;
        index index.html;
        try_files $uri /index.html break;
    }
	
    location ~ /swagger-ui-assets {
       index index.php;
       try_files $uri $uri/ /index.php?$query_string;
    }
	
	#location ~ /docs-api {
	location ~ /docs-.+$ {
       index index.php;
       try_files $uri $uri/ /index.php?$query_string;
    }
	
	location ~ /.+/documentation$ {
       index index.php;
       try_files $uri $uri/ /index.php?$query_string;
    }
	
	location ^~ /api {
        index index.php;
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php$ {
		root $php_root;
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;		
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
	
	location ^~ /uploads {
		root $pic_root;
    }
	
	
    charset utf-8;
	
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

  

自定義變量,正則匹配

 

參考:https://blog.csdn.net/xyang81/article/details/51989079


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM