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