跳至正文
  • 15 views
  • 1 min read

typecho只能打开主页,文章详细内容打不开

新浪微博 豆瓣 QQ 百度贴吧 QQ空间

问题描述:
安装了typecho显示成功安装,但是前端只显示标题和摘要,点击查看不了详细内容。

问题原因:
PHP这块不支持pathinfo,

官网提供的解决方案有一定参考性,但是不能完全复用

http://docs.typecho.org/servers

经过多次测试,将 Nginx 的 PHP 段改成如下形式,就可以访问文章详细信息了

location ~ .*\.php(\/.*)*$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_split_path_info ^(.+?.php)(/.*)$;
    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$real_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    include        fastcgi_params;
}

也就是添加 fastcgi_split_path_info ^(.+?.php)(/.*)$; 由 Nginx 设置 PATH_INFO 值。

然后重启服务使配置生效。

sudo systemctl restart nginx
sudo systemctl restart php-fpm

ok,可以访问了。

转载于:https://www.cnblogs.com/zhaijiahui/p/8478223.html

发表回复