h5ai 中文目录及文件均为乱码404无法下载解决办法

 经常布置服务器,所以想搞一个软件仓库,找了下h5ai看着挺好,目前部署在windows下upupw的运行环境,会有中文目录显示乱码,打开 中文目录提示404的问题。

这里修改两行代码即可解决:

\_h5ai\private\php\core\class-context.php

public function to_href($path, $trailing_slash = true) {
$rel_path = substr($path, strlen($this->setup->get(‘ROOT_PATH’)));
$parts = explode(‘/’, $rel_path);
$encoded_parts = [];
foreach ($parts as $part) {
if ($part != ”) {
$encoded_parts[] = rawurlencode(mb_convert_encoding($part, "UTF-8", "GBK")); //rawurlencode($part);
}
}

return Util::normalize_path($this->setup->get(‘ROOT_HREF’) . implode(‘/’, $encoded_parts), $trailing_slash);
}

public function to_path($href) {
$rel_href = substr($href, strlen($this->setup->get(‘ROOT_HREF’)));
return Util::normalize_path($this->setup->get(‘ROOT_PATH’) . ‘/’ . iconv( ‘UTF-8’, ‘GBK’, rawurldecode($rel_href) ));//rawurldecode($rel_href));
}

找到上面这两个函数,将红色部分修改为上面代码即可。

One Comment on “h5ai 中文目录及文件均为乱码404无法下载解决办法”

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注