docker搭建的wordpress,nignx反向代理访问,nginx加上ssl后,访问WordPress,结果页面里js css仍是http请求。解决办法以下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); }
$_SERVER['HTTPS'] = 'on'; define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.xxx.com','https://www.xxx.com') WHERE post_content LIKE '%http://www.xxx.com%';