7ehost
全球服务器主机

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

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

1.enable-php.conf 文7ehst件,添加pathinfo2.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遇到。

未经允许不得转载:7eHost全球服务器资源 » LNMP – pathinfo设置:解决typecho后台或其它404错误

更好的更稳定的服务器

7EHOST从事服务器多年经验积累和风险预测,确保企业型服务能够满足我们大/小客户需求。所有机房电话,邮件,工单提供24/7/365全年全天候技术支持,服务器在线率99.99%。

联系我们联系我们