Get Off My Lawn
Get Off My Lawn

Reputation: 36291

Nginx rewrite is giving 404

I am not sure why, but I am getting a 404 when ever I hit my pages, here is my rewrite:

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

Works:

/dashboard/

Doesn't work (gives 404):

/dashboard/page1
/dashboard/page2

Is there something wrong with my rewrite?

Here is my server file, the rewrite is in the include

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;
    }
}

Error from log:

2015/07/13 01:53:00 [error] 14712#0: *9613 open() "/usr/share/nginx/html/cleep.us/publicindex.html" failed (2: No such file or directory ), client: 24.197.220.192, server: cleep.us, request: "GET /dashboard/clicks HTTP/1.1", host: "cleep.us"

Upvotes: 0

Views: 1106

Answers (1)

Get Off My Lawn
Get Off My Lawn

Reputation: 36291

Looks like this is what will fix my issue, it works now. If there is a better way please let me know.

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

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

Upvotes: 1

Related Questions