crazyjingling 2011-05-18
nginx+php+wordpress 3.1的环境下,
所有图片下载完成后,Firefox显示"图像 “XXXX” 因其本身有错无法显示。" , FireBug显示”Image corrupt or truncated“
把图片下载下来,用16进制编辑器打开,发现比通常的文件头多了”EF BB BF“,这显然是UTF8的DOM签名。
估计是伪静态转接时,没有清理干净。
打开wp-includes/ms-files.php
在最后
// If we made it this far, just serve the file
readfile( $file );
改为
// If we made it this far, just serve the file
// fix utf-8 dom
ob_clean();
flush();
readfile( $file );
flush();
即可。
--------------------------------------------------------------------------------
另附ngnix伪静态配置
SubDomain 子域名模式:
#on server block
##necessary if using a multi-site plugin
server_name_in_redirect off;
##necessary if running Nginx behind a reverse-proxy
port_in_redirect off;
rewrite ^/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^ /index.php last;
}
SubFolder 子目录模式:
#on server block
##necessary if using a multi-site plugin
server_name_in_redirect off;
##necessary if running Nginx behind a reverse-proxy
port_in_redirect off;
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
升级为多站点后,原主站可能发生文章链接404的情况,进后台重新选个”固定链接“的格式,修改下即可。