【问题标题】:Nginx rewrite is giving 404Nginx 重写给出 404
【发布时间】:2015-07-13 14:01:49
【问题描述】:

我不知道为什么,但是每次我点击我的页面时都会收到 404,这是我的重写:

rewrite ^dashboard/(.+)$ /dashboard/index.html?path=$1;

作品:

/dashboard/

不起作用(给出 404):

/dashboard/page1
/dashboard/page2

我的重写有什么问题吗?

这是我的服务器文件,rewriteinclude

server{
    listen 80;

    server_name    cleep.us www.cleep.us;
    root           /usr/share/nginx/html/cleep.us/public;
    index          index.html index.php;

    location / {
        try_files $uri $uri/ index.html;
        include /usr/share/nginx/conf/cleep.us.conf;
    }
}

来自日志的错误:

2015/07/13 01:53:00 [错误] 14712#0: *9613 open() "/usr/share/nginx/html/cleep.us/publicindex.html" 失败(2:没有这样的文件或目录),客户端:24.197.220.192,服务器:cleep.us,请求:“GET /dashboard/clicks HTTP/1.1”,主机:“cleep.us”

【问题讨论】:

  • 你能把nginx的错误日志包括进来吗?
  • 加了,好像没放斜线什么的

标签: nginx rewrite


【解决方案1】:

看起来这将解决我的问题,现在可以了。如果有更好的方法请告诉我。

location / {
    try_files $uri $uri/ index.html;
}

location /dashboard {
    try_files $uri $uri/ /dashboard/index.html;
    include /usr/share/nginx/conf/cleep.us.conf;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-06
    • 2017-04-06
    • 1970-01-01
    • 2018-07-25
    • 2023-01-16
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    相关资源
    最近更新 更多