alphardex
V2EX  ›  问与答

vue history 路由部署到子目录访问 404

  •  
  •   alphardex · Jun 15, 2021 · 1625 views
    This topic created in 1795 days ago, the information mentioned may be changed or developed.

    开发了一个 vue 项目,用了 history 路由,分别部署在了 pc 和 wap 两个子目录下,根据官方的服务器配置说明进行了如下的服务器( nginx )配置

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

    但项目上线后随意访问一个子路径,刷新后还是 404,应该怎么解决,有老哥遇到过类似的问题吗

    补充: 项目根目录下放了 index.html,用来根据 ua 判断进入 pc (电脑端)还是 wap (移动端)目录

    Supplement 1  ·  Jun 16, 2021
    本问题已解决
    3 replies    2021-06-15 18:33:53 +08:00
    dagouziwangwang
        1
    dagouziwangwang  
       Jun 15, 2021
    需要指定一下 alias
    canbingzt
        2
    canbingzt  
       Jun 15, 2021
    还需要配置下 publicPath
    IvanLi127
        3
    IvanLi127  
       Jun 15, 2021 via Android
    你刷新前 地址是啥
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4464 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 10:07 · PVG 18:07 · LAX 03:07 · JFK 06:07
    ♥ Do have faith in what you're doing.