Home  >  Article  >  Operation and Maintenance  >  How to configure PATHINFO in Nginx to hide thinkphp index.php

How to configure PATHINFO in Nginx to hide thinkphp index.php

WBOY
WBOYforward
2023-06-03 13:18:14883browse

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

The above is the detailed content of How to configure PATHINFO in Nginx to hide thinkphp index.php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete