nginx环境下 TP5中路由404问题怎么解决?

冰久 2018-09-06 03:52:24
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;
}
...全文
1430 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
冰久 2018-09-07
  • 打赏
  • 举报
回复
在index.php/加入路由可以实现路由功能,然后在nginx.config中修改location / { }中的代码之后可以实现 public/路由 的功能。
location / {
index index.html index.htm index.php l.php;
autoindex off;
if ( !-e $request_filename) {
rewrite ^/tp51/public/(.*)$ /tp51/public/index.php/$1 last; #tp51为tp5项目的文件夹;

break;

}
u48 2018-09-07
  • 打赏
  • 举报
回复
忘了说了,这个能解决linux+nginx 404问题。
u48 2018-09-07
  • 打赏
  • 举报
回复
我之前也遇到过这样的问题,你先试试,xxx.com/index.php?s=index/index/index,是否可以正常打开,如果可以,你用以下代码:

location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php($|/){
set $script $uri;
set $path_info “”;
if ($uri ~ “^(.+?\.php)(/.+)$”) {
set $script $1;
set $path_info $2;
}
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param script_FILENAME $document_root$script;
fastcgi_param script_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
冰久 2018-09-06
  • 打赏
  • 举报
回复

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧