如果有一种方法可以不使用别名来完成这个典型的任务,我完全可以。
我希望/minesweeper/* URL中的所有请求都被从完全不同的目录中提取,而不是其他请求。 下面的configuration工作,文件被提供,但MIMEtypes是应用程序/八位字节stream,而不是它应该是(即文本/ CSS)。 使用不正确的MIMEtypes,Web浏览器不可能在文档中呈现CSS样式。
nginx.conf: http { index index.html include /etc/nginx/mime.types; default_type application/octet-stream; ... } virtual.conf: server { listen *:80; server_name djmp.org www.djmp.org; root /home/devsites/djmp.org/public_html/; index index.html; location ~ ^/minesweeper($|/.*) { alias /home/michael/sites/minesweeper$1; } }
使用alias会很好,但你不需要那个正则expression式废话。
location /minesweeper/ { alias /home/michael/sites/minesweeper/; }
我通过不使用别名解决了这个问题。 此外,我不得不删除caching在Chrome中,否则它实际上并没有得到新的MIMEtypes! 我检查了Firefox,它工作。
server { listen *:80; server_name djmp.org www.djmp.org; root /home/devsites/djmp.org/public_html/; index index.html; include /etc/nginx/mime.types; location /minesweeper { root /home/michael/sites/; # choose the parent directory here index index.html index.htm; } }