【发布时间】:2013-07-30 09:26:02
【问题描述】:
我想在 nginx 配置中为 url "localhost/test/" 设置一个位置指令。
我在配置文件中尝试了以下内容:
server {
listen 80;
server_name localhost;
location /test/ {
root /home/test;
index index.html index.htm
}
}
这总是给我一个 404 错误。然后我尝试了这个
server {
listen 80;
server_name localhost;
location / {
root /home/test;
index index.html index.htm
}
}
它在 url "localhost" 上运行良好
我不明白为什么它在第一种情况下会抛出 404 错误!
【问题讨论】:
-
你试过 localhost/test,去掉最后的'/'吗?
-
你能在 /test/ 案例中将 root 设为别名并更新我吗
-
不一样!!
-
我使用了位置 /test/ { 别名 /home/test;索引 index.html index.htm }
-
您添加虚拟 / 并尝试在 /test/ 中使用 root。
标签: nginx