How to configure Hidden index.php? for nginx phpstudy

windows system phpstudy integrated environment, nginx service, after the installation of laravel, except the home page can be accessed, the registration and login pages after make:auth can not be accessed. To find the reason on the Internet, just write index.php after the domain name, and then know that it is the problem of pathinfo. Add a line to the vhosts.conf file of nginx according to the instructions of the document

.
try_files $uri $uri/ /index.php?$query_string;

this is the content of my vhost.conf configuration file, and nothing else has been moved except for the above line:

server {
        listen       80;
        server_name  laravel.demo.com ;
        root   "E:/pms/laravel/public";
        location / {
            index  index.html index.htm index.php;
            -sharpautoindex  on;
            try_files $uri $uri/ /index.php?$query_string;
        }
        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;
        }
}

now the address automatically adds index.php, but according to the document, adding the try_files line is to beautify the url, but it automatically adds the index.php. How to hide the index.php?? I checked on the Internet, and the configuration file is written by default, ask for help from the boss, see where the problem is?

Feb.28,2021

I remember that nginx.conf has several basic server rules by default. You clear them all, leaving only include vhosts.conf to try ~

.

attach my own configuration:

nginx.conf

server {
    listen       80;
    server_name  localhost;

    root    "X:/www";
    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    error_page 404              /404.html;
    error_page 500 502 503 504  /50x.html;

    location = /50x.html {
        root html;
    }

    location ~ \.php(.*)$  {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include fastcgi_params;
        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;
        try_files $uri =404;
    }

    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

(in fact, basically nothing has been added, it's all the original ones.)

Menu