Maison  >  Article  >  Opération et maintenance  >  Comment configurer PATHINFO dans Nginx pour masquer thinkphp index.php

Comment configurer PATHINFO dans Nginx pour masquer thinkphp index.php

WBOY
WBOYavant
2023-06-03 13:18:14883parcourir

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

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer