wordpress如何开启全站https

第一步:系统文件修改

1,修改的路径:\wp-includes\functions.php文件
2,打开修改functions.php文件,找到代码 require( ABSPATH . WPINC . ‘/option.php’ ); 在下方添加:

add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2);
function agnostic_script_loader_src($src, $handle) {
return preg_replace('/^(http|https):/', '', $src);
}
add_filter('style_loader_src', 'agnostic_style_loader_src', 20,2);
function agnostic_style_loader_src($src, $handle) {
return preg_replace('/^(http|https):/', '', $src);
}

第二步:配置文件修改

路径:在wordpress网站根目录中找到,wp-config.php文件,在文件开头位置中,添加如下代码:

$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

第三步:修改网站后台的https修改

版权声明:GameAI 发表于 2025-02-18 0:06:06。
转载请注明:wordpress如何开启全站https | 游戏制作编程设计知识收集分享网站