刚接触typecho,还处在把程序成功架起来的阶段。遇到一个lnmp环境下rewrite小问题
访问某些文件类型不存在的文件,如xxx.html、xxx.log、xxx.txt等,能够显示主题自定义404内容,但是访问一个不存在的PHP、css、js等文件,还是返回nginx默认的404页面。
下面是我的配置:
nginx.conf
========
server
{
listen xx.xx.xx.xx:80;
#listen [::]:80;
server_name xx.com www.xx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/vhosts/xx;
include typecho.conf;
location ~ [^/]\.php(/|$)
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
-------------------------------------------------------------------------
typecho.conf
========
location / {
index index.html index.php;
if (-e $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-e $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-e $request_filename){
rewrite (.*) /index.php;
}
}
-------------------------------------------------------------------------
pathinfo.conf
========
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name = 404;
后来想到一个办法,
把 pathinfo.conf 中的
try_files $fastcgi_script_name = 404;
换成:
try_files $uri $uri/ /index.php?/$uri;
貌似可以了,把404都传递给typecho解决了,但是又出了新的问题:后台登录不了 -- 点击登录后没反应,或者说又跳回登录前界面了。
不知道怎么解决。
另外还有个后台路径修改的小问题,官方文档介绍了方法,但是我发现这个方法没什么用处,修改路径后,在URL访问/index.php/action/login可以直接跳转到后台登录,隐藏后台也就没有意义了。