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;
          }
      }

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2021-04-11
  • 2021-09-18
  • 2021-08-14
  • 2022-01-05
  • 2021-08-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
相关资源
相似解决方案