typecho
typecho copied to clipboard
求助typecho nginx子目录伪静态规则
http:///www.xxx.com/blog/ 子目录 blog 的伪静态试了好几个方法都不行,404错误页面,应该怎么解决呢。
无效方法一: location /blog/ { if (!-e $request_filename){ rewrite ^/blog/(.*)$ /blog/index.php; } }
无效方法二: location /blog/ { 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 (.*) /blog/index.php; } }
难道是服务器nginx.conf需要什么地方修改吗?
尝试修改typecho后台伪静态规则,也在路径加上 /blog
http://www.xxx.com/blog/index.php/default/start.html
页面都带有 /index.php/xxx 无法打开
使用 Nginx 驱动 typecho,刚安装后可以看到首页却不能访问管理登录页面,按照这个 blog 修改了 nginx 配置后,问题解决。然后却发现,输入用户名密码后提示 Access denied.
在log中看到如下:
2014/10/15 23:10:28 [error] 4342#0: *17 FastCGI sent in stderr: "Access to the script '/usr/share/nginx/typecho/index.php/action/login' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 192.168.199.212, server: localhost, request: "POST /index.php/action/login?_=b2389d8dc2c8f5a132342d4d79d0fed6 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.199.20", referrer: "http://192.168.199.20/admin/login.php"
Google 后找到这么一篇文章 http://askubuntu.com/questions/164627/nginx-php-fpm-access-denied-error 提示 cgi.fix_pathinfo
应该为 1,在 /etc/php5/fpm/php.ini
中修改完毕。
最后,重启 php5-fpm 和 nginx 服务,便可以正确登录管理页面。
以前一直是 cgi.fix_pathinfo = 1
. 后来忘记在哪看的, 说 nginx 官方对 php-fpm 的支持有了优化,具体是 fix_pathinfo = 0
然后 nginx 配置里加了 fastcgi_split_path_info
这一项.
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params; }
我测试可行. 有兴趣的可以试试.
@ilaotan 困扰几天的问题。。解决了 感谢。
@ilaotan 解决了。。。网上的都没用。。谢谢
伪静态设置 默认的typecho网页链接中总带着一个index.php,那么有没有办法把这个链接美化一下呢?我们需要开启typecho的伪静态。首先编辑nginx的站点文件,在server大括号中加入
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;
}