目前的配置文件和文件结构
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 70;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
}
在demo目录下有一个index.html和home.html
需要配置
访问 localhost:90/demo, 加载demo下的index.html
访问 localhost:90/demo/home, 加载demo下的home.html
应该怎么写?
我试了下在和 server 同级加了一个 server
server {
listen 90;
server_name localhost;
location /demo {
root demo;
index index.html index.htm;
}
}
但是没有效果, 访问是404, 不是很理解 这种写法有什么问题吗?
1.对于localhost:90/demo 这个请求,你当前的配置应该是访问到了demo/demo/这里去了;
2.对于localhost:90/demo/home 这个请求你的配置是访问到了demo/demo/home/这里去了;
显然这两个目录都不存在。