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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM