首頁  >  文章  >  運維  >  Nginx怎麼配置PATHINFO隱藏thinkphp index.php

Nginx怎麼配置PATHINFO隱藏thinkphp index.php

WBOY
WBOY轉載
2023-06-03 13:18:14882瀏覽

nginx配置pathinfo隐藏index.php
nginx配置文件里放入这段代码

server { 
  listen    80;
  default_type text/plain;
  root /var/www/html;
  index index.php index.htm index.html;
 #隐藏index.php
  location / {
     if (!-e $request_filename) {
          #一级目录
         # rewrite ^/(.*)$ /index.php/$1 last;
          #二级目录
          rewrite ^/myapp/(.*)$ /myapp/index.php/$1 last;
       } 
  }
 #pathinfo设置
    location ~ \.php($|/) {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_split_path_info ^(.+\.php)(.*)$;
      fastcgi_param  path_info $fastcgi_path_info;
      fastcgi_param script_filename  $document_root$fastcgi_script_name;
      include    fastcgi_params;
    }
 }

以上是Nginx怎麼配置PATHINFO隱藏thinkphp index.php的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除