假设,wordpress站点中各个文件或者页面的路径是绝对路径如:
https://www.abc.com/images/logo.png
若在源代码中显示成:
/images/logo.png
可以尝试使用下面的代码:
add_action("template_redirect", "start_buffer");
add_action("shutdown", "end_buffer", 999);
function filter_buffer($buffer)
{
$buffer = replace_insecure_links($buffer);
return $buffer;
}
function start_buffer()
{
ob_start("filter_buffer");
}
function end_buffer()
{
if (ob_get_length()) {
ob_end_flush();
}
}
function replace_insecure_links($str)
{
$str = str_replace(array("http://www.abc.com/", "https://www.abc.com/"), array("/", "/"), $str);
return apply_filters("rsssl_fixer_output", $str);
}
评论区
发表新的留言
您可以留言提出您的疑问或建议。
您的留言得到回复时,会通过您填写的邮箱提醒您。