nginx: send all requests to a single html page

前端 未结 6 2063
南笙
南笙 2020-11-30 17:45

Using nginx, I want to preserve the url, but actually load the same page no matter what. I will use the url with History.getState() to route the requests in my

6条回答
  •  生来不讨喜
    2020-11-30 18:09

    Using just try_files didn't work for me - it caused a rewrite or internal redirection cycle error in my logs.

    The Nginx docs had some additional details:

    http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files

    So I ended up using the following:

    root /var/www/mysite;
    
    location / {
        try_files $uri /base.html;
    }
    
    location = /base.html {
        expires 30s;
    }
    

提交回复
热议问题