• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
陶阳昊
开发有风险,入坑需谨慎
博客园    首页    新随笔    联系   管理    订阅  订阅

nginx----------路由规则配置

1、前端写了一套带有vue路由的的功能。放到nginx配置的目录下以后,刷新会报404未找到。

  这是根据实际情况来写的。

  location /h5/activity/wechat/ {
            index  index.html index.htm index.php;
            try_files $uri $uri/ /h5/activity/wechat/index.html;
        }

  

  这是项目直接放在根目录下的情况。

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

 2、nginx路由规则配置

  location / {
            index index.html index.htm index.php l.php;
            autoindex  off;
            try_files $uri $uri/ /index.php?$query_string;
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php  last;
                break;
            }
        }

 

  location / {
             index index.html index.htm index.php;
          if (!-e  $request_filename) {
                rewrite ^/api/(.*)$ /api.php?s=$1 last;
          }
          if (!-e  $request_filename) {
                rewrite ^/(.*)$ /index.php?s=$1 last;
          }
      }

posted @ 2018-05-21 13:08  陶阳昊  阅读(3343)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3