phpstudy nginx去掉index.php

PHPstudy打开文件位置:PHPstudy、其他选项菜单、打开文件位置、php中文网、nginx、conf。

nginx.conf文件

    server {
        listen       80;
        server_name  localhost;
        root    "D:/phpstudy/PHPTutorial/WWW";
        location / {
           index  index.html index.htm index.php l.php;
           autoindex  on;

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

vhosts.conf文件

主要添加

            if (!-e $request_filename){  
              rewrite ^/(.*) /index.php last;  
            }  
server {
        listen       80;
        server_name  api.yoo.com yoo.com;
        root   "D:\phpstudy\PHPTutorial\WWW\yoofree\api\web";
        location / {
            index  index.html index.htm index.php;
            #autoindex  on;
            if (!-e $request_filename){  
              rewrite ^/(.*) /index.php last;  
            }  
        }
        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;
        }
}

你可能感兴趣的:(YII2)