我需要在我的Web服务器上使用NGINX规则的特殊目录覆盖,以便适用于/ var/www/acme的关于CSS,JS等的规则不适用于/ var/www/acme /特别。我有一个/ var/www包含me.com下的我的网站(127.0.0.1本地主机设置)。在那里,我有一个acme文件夹,它为我的PHP使用了一个特殊的框架。不过,我有一个文件夹/ var/www/acme/special,它不需要应用这些相同的规则,而只需像普通的PHP网站一样运行。我被卡住了,因为当我使用特殊位置的逻辑和try_files例程以及/ var/www/acme/special中断时,我得到一个HTTP 500错误,指出“在内部重写或内部重定向循环重定向到'/ acme/special ////////////“。NGINX的目录覆盖
这是我在Ubuntu 16.04上的NGINX的/etc/nginx/sites-available/me.com文件。我究竟做错了什么?
server {
listen 80;
listen [::]:80;
root /var/www;
index index.php index.html;
server_name me.com www.me.com;
location /acme/special {
try_files $uri $uri/;
break;
}
location ~ ^/acme/(.*(?<!boot))/css/(.*)$ {
alias /var/www/acme/$1/views/assets/css/$2;
}
location ~ ^/acme/(.*(?<!boot))/js/(.*)$ {
alias /var/www/acme/$1/views/assets/js/$2;
}
location ~ ^/acme/(.*(?<!boot))/img/(.*)$ {
alias /var/www/acme/$1/views/assets/img/$2;
}
location ~ ^/acme/(.*)/fonts/(.*(?<!boot))$ {
alias /var/www/acme/$1/views/assets/fonts/$2;
}
location ~ ^/acme/(.*)/boot/(.*)$ {
alias /var/www/acme/$1/views/assets/boot/$2;
}
location/{
try_files $uri $uri/ @php;
}
location @php {
rewrite ^/acme/([^\/]+)/.*((?!index\.php).)*$ /acme/$1/index.php?query_string last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}