User-Profile-Image
hankin
  • 5
  • 首页
  • Dedecms
  • Notes
  • php
  • Tools
  • Music
  • 分类
    • Tools
    • php
    • Notes
    • Music
    • Dedecms
  • 页面
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
  • 首页
  • Dedecms
  • Notes
  • php
  • Tools
  • Music
    首页   ›   Notes   ›   正文
Notes

wordpress开启全站https方法

2018-10-15 16:02:16
5495  0 0

时隔多少年又折腾起了blog,买了新域名新服务器,把BAE的数据迁过来。开启https的时候遇到了好多问题,前台后台重定向循环,皮肤文件不是https等等,折腾了半天终于好了。
方法总结如下:

1.皮肤文件目录functions.php
在最后添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
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");
}
}

2.网站根目录\wp-config.php
找到代码:

1
2
3
4
5
*
 
* @package WordPress
 
*/

在下方添加如下代码:

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

3.登入后台
修改设置里的 “WordPress地址(URL)”和“站点地址(URL)”为带https的,例如:https://alvin.cool

评论 (0)

点击这里取消回复。

欢迎您 游客  

Archives
  • 2019年4月
  • 2018年10月
  • 2018年5月
  • 2018年2月
  • 2016年7月
  • 2015年12月
  • 2014年9月
  • 2014年3月
  • 2014年1月
  • 2013年12月
  • 2013年11月
Categories
  • Dedecms
  • Music
  • Notes
  • php
  • Tools
标签
Dedecms Dedecms短信 Dedecms自定义表单 dedecms自定义表单必填字段 dede_fieldshash showmsg sitemap 织梦 网站地图 自定义表单短信
其他操作
  • 登录
  • 条目feed
  • 评论feed
  • WordPress.org
Copyright © 2025
smarty_hankin 主题. Designed by hankin
主页
页面
博主
Alvin 管理员
14 文章 0 评论 57365 浏览
测试
测试