自从用laravel框架后,好久没用过thinkphp框架了,早期用的3.x系列,想熟悉一下thinkphp5,结果入坑了;
路由配置一直不起作用,总是跳到首页,折腾了好久,后来发现是nginx配置的问题,找了好多文章后来发现官方文档上是有说明的,只是隐藏得比较深,没注意看;加上加粗部分的配置就好了
server {
listen 80;
location / {
root /share/tp5_app/public;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
#pathinfo支持
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /share/tp5_app/public$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}