在当前使用主题文件:function.php 加入以下代码
add_filter('get_header', 'fanly_ssl');
function fanly_ssl(){
if( is_ssl() ){
function fanly_ssl_main ($content){
$siteurl = get_option('siteurl');
$upload_dir = wp_upload_dir();
$content = str_replace( 'http:'.strstr($siteurl, '//'), 'https:'.strstr($siteurl, '//'), $content);
$content = str_replace( 'http:'.strstr($upload_dir['baseurl'], '//'), 'https:'.strstr($upload_dir['baseurl'], '//'), $content);
return $content;
}
ob_start("fanly_ssl_main");
}
}
wp-config.php文件中添加:
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
新建“.htaccess”添加伪静态规则:
RewriteCond %{HTTPS} !on [NC]
RewriteRule (.*) https://域名%{REQUEST_URI} [R=301,NC,L]
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容