首页  >  问答  >  正文

nginx 所有页面指向index.html

nginx 怎么把所有页面都指向一个目录的index.html 比如我访问 /aa/ 和/aa/aa/ /cc/
都指向一个文件

高洛峰高洛峰2712 天前701

全部回复(2)我来回复

  • ringa_lee

    ringa_lee2017-05-16 17:16:04

    这个跟nginx没什么关系吧。nginx设置一个转发的地址,然后监听这个地址的wsgi服务器可以把你想要的路由指向你想要去的这个文件。

    回复
    0
  • ringa_lee

    ringa_lee2017-05-16 17:16:04

    在目录/path/to/html放个文件hello.html,
    配置如下:

    server {
        listen 4080;
        location / {
            try_files '' /path/to/html;
        }
        location = /hello.html {
            root /path/to/html;
        }
    }

    回复
    0
  • 取消回复