windows系统 phpstudy集成环境,nginx服务, 安装laravel后除了首页可以访问,make:auth后的注册和登录页面都不能访问,网上查找原因发现只要在域名后面把index.php写上就行,然后知道是pathinfo 的问题,在nginx的vhosts.conf文件上按照文档的指导加了一行
try_files $uri $uri/ /index.php?$query_string;
这个是我的vhost.conf配置文件内容,除了上面一行,其它都没动:
server {
listen 80;
server_name laravel.demo.com ;
root "E:/pms/laravel/public";
location / {
index index.html index.htm index.php;
#autoindex 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;
}
}
现在倒是地址自动添加index.php了,但是按照文档所说,加上try_files那一行是为了美化url, 但是反而是自动添加index.php了,怎么隐藏这个index.php?我网上查的,和配置文件默认的写法一样,求助大佬,看看是哪里的问题?
我记得nginx.conf默认有几条基础的server规则,你把它都清掉,只留下
include vhosts.conf
试试~附上我自己的配置:
nginx.conf
vhosts.conf
(其实基本没加什么,都是原来那些……)