配置nginx
server {
listen 80;
server_name www.test.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/website;
index index.html index.htm;
}
location /resources {
alias /usr/local/nginx/resources; #资源文件夹路径
autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
下面就可以访问localhost/resources了
效果:
显示中文乱码问题解决:
如果遇到文件夹里面的中文资源名称出现乱码,修改nginx,加上 charset utf-8;
server {
listen 80;
server_name www.test.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/website;
index index.html index.htm;
}
location /resources {
alias /usr/local/nginx/resources;
autoindex on;
charset utf-8; #解决中文乱码问题
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}