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