nginx - redirect subdirectories path to single (index.html) file

空扰寡人 提交于 2019-12-12 02:20:04

问题


How to redirect all the sub directory path to single index.html file?

here is what i want nginx configuration:

location /user/* {
    alias /home/vishant/devcenter/baetter-share1;
    index index.html;
}

this means if i hit /user OR /user/vishant OR /user/xyz/vishant it should render only index.html page.

The code i have written is not working but what i thought should be similar to this.


回答1:


location /user/ {
    root /home/vishant/devcenter/baetter-share1;
    try_files /index.html =404;
}

Documentation:

  • location
  • root
  • try_files


来源:https://stackoverflow.com/questions/39745315/nginx-redirect-subdirectories-path-to-single-index-html-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!