Nginx configuration PATHINFO hide thinkphp index.php

  • 2020-05-09 19:58:05
  • OfStack

Nginx configuration PATHINFO hidden index.php
Put this code in the Nginx configuration file


server { 
  listen    80;
  default_type text/plain;
  root /var/www/html;
  index index.php index.htm index.html;
 # hidden index.php
  location / {
     if (!-e $request_filename) {
          #1 Level directory 
         # rewrite ^/(.*)$ /index.php/$1 last;
          #2 Level directory 
          rewrite ^/MYAPP/(.*)$ /MYAPP/index.php/$1 last;
       } 
  }
 #pathinfo Set up the 
    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;
    }
 }


Related articles: