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%';