>  기사  >  백엔드 개발  >  Nginx에서 숨겨진 항목 파일 index.php를 구성하는 방법(코드)

Nginx에서 숨겨진 항목 파일 index.php를 구성하는 방법(코드)

不言
不言원래의
2018-08-01 11:29:104242검색

这篇文章给大家介绍的内容是关于Nginx配置 隐藏入口文件index.php,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

Nginx配置文件里放入这段代码

server {
    location / {
        index index.php index.html index.htm l.php;
        autoindex  on;
        
        if (!-e $request_filename) {
      #一级目录
     # rewrite ^/(.*)$ /index.php/$1 last;
      #二级目录,这里注意修改成自己的项目目录
      rewrite ^/rent/public/(.*)$ /rent/public/index.php/$1 last;
   } 
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php(.*)$  {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
}

相关推荐:

ThinkPHP通过URL重写应用的index.php

mvc模式中

PHP怎样

위 내용은 Nginx에서 숨겨진 항목 파일 index.php를 구성하는 방법(코드)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.