Centos7 thinphp5 nginx hidden index.php and pathinfo mode configuration

Source: Internet
Author: User

Enter Nginx directory and open nginx.conf
For example, the URL of my visit to thinkphp is (TP5 is the directory I created under nginx/html/, called the level Two directory below): Https://192.168.139.128/tp5/index.php?s=index/index/index
PathInfo mode is not supported now
1, let Nginx support PathInfo mode, you can access Url:https://192.168.139.128/tp5/index.php/index/index/index
Will

Location ~ \.php$ {
            root           html;
            Fastcgi_pass   127.0.0.1:9000;
            Fastcgi_index  index.php;
            Fastcgi_param  script_filename  $document _root$fastcgi_script_name;
            I

Nclude Fastcgi_params;
}
Modified into
Location ~ \.php ($|/) {
            root           html;
            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;
        }




2, followed by the hiding out index.php
This code is added so that you don't need to enter index.php:https://192.168.139.128/tp5/index/index/index in the URL
Location/{
            root   html;
            Index  index.php index.html index.htm;
            if (!-e $request _filename) {
                # # #一级目录下
        	#rewrite ^/(. *) $/index.php/$1 last;
                # # #域名下的二级目录
                rewrite ^/tp5/(. *) $/tp5/index.php/$1 last;
            }
        }


3, restart Nginx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.