LNMP - pathinfo设置:解决typecho后台或其它404错误

发布时间:2022-06-23 09:59 来源:资源部落 阅读:76 作者:资源部落 栏目: 经验分享 欢迎投稿:712375056

现在使用lnmp1.x版本,搭配登陆后台,会出现404错误。就不深究原因了,这里只说解决办法。

1.enable-php.conf 文件,添加2.conf引入

  location ~ [^/].php(/|$)
        {
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            include pathinfo2.conf;
        }

2.上传pathinfo2.conf文件(和原来默认版本不一样)

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 $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;

3.如果除首页外全部404,则为规则问题,请使用以下伪静态规则:

location /
{
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

以上问题,主要常见于lnmp1.3-beta版本,主要为typecho遇到。

来源链接:https://www.zyhot.com/article/881.html

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

免责声明:本站发布的内容(图片、视频和文字)以原创、来自本网站内容采集于网络互联网转载等其它媒体和分享为主,内容观点不代表本网站立场,如侵犯了原作者的版权,请告知一经查实,将立刻删除涉嫌侵权内容,联系我们QQ:712375056,同时欢迎投稿传递力量。