nginx配置文件重寫url不帶index.php


如題:

代碼

location / {


        root   /項目目錄/;
        index  index.php;

        if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
                rewrite (.*) /index.php;
        }

      #如果請求既不是一個文件,也不是一個目錄,則執行一下重寫規則 thinkphp 部署到linux 下常用
      if (!-e $request_filename)
      {
        #地址作為將參數rewrite到index.php上。
        rewrite ^/(.*)$ /index.php/$1;
        #若是子目錄則使用下面這句,將subdir改成目錄名稱即可。
        #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
      }




}

就這么簡單

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM