关于nginx location 配置相关资料很多,由于在配置location时候老是出现404 not found,查阅了很多资料,总算是找到了答案。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /hsc {
root /home/hsc/nginx;
index index.html;
}
location / {
root /home/hsc/nginx/hsc;
index index.html index.htm;
}
}如上一个简单server配置,在浏览器中输入127.0.0.1 和127.0.0.1/hsc其请求的结果是一样都是/home/hsc/nginx/hsc 目录下的index.html
解释下:127.0.0.1 会匹配到 location / 然后 root(表示根目录) 为/home/hsc/nginx/hsc 然后nginx 再去找/后面的内容这里为空,所以就找根目录下的内容。
95Shop可以免费下载使用,是一款仿醉品商城网店系统,内置SEO优化,具有模块丰富、管理简洁直观,操作易用等特点,系统功能完整,运行速度较快,采用ASP.NET(C#)技术开发,配合SQL Serve2000数据库存储数据,运行环境为微软ASP.NET 2.0。95Shop官方网站定期开发新功能和维护升级。可以放心使用! 安装运行方法 1、下载软件压缩包; 2、将下载的软件压缩包解压缩,得到we
27.0.0.1/hsc 会匹配到 llocation /hsc 然后 root(表示根目录) 为/home/hsc/nginx 然后nginx 再去找/后面的内容这里为hsc这个目录,所以就会切换到/home/hsc/nginx/hsc目录下。
以上就介绍了Nginx location 配置心得,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。









