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