环境配置:框架是ThinkPHP5.08,环境是用phpStudy选的nginx环境;
问题现象:访问配置的虚拟目录时,可以访问到框架的入口文件,但无法访问到虚拟目录对应的模块(启用了项目分组)。
问题出现原因:集成环境自动生成的vhost.conf文件中缺少两行配置语句句
if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; }
这两句话的意思是指,如果请求的文件不存在,则进行路径的重写;
改完以后的vhost.conf文件内容为:
server { listen 80; # 网站域名 server_name local.taihaowan.cn taihaowan.cn; # 代码根目录 root "E:/code/ths"; location / { # 默认请求的文件排序 index index.html index.htm index.php; # 判断请求的文件是否存在 if (!-e $request_filename) { # 如果不存在就进行重定向 rewrite ^/(.*)$ /index.php/$1 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; } }