HTTPS已经成为网站的一种趋势,得益于数以万计的开发者和百万计的玩家,Wordpress启用HTTPS过程相当简单。下面就把Wordpress启用HTTPS访问的过程记录一下,以供参考。
一、 修改网站WP_HOME和WP_SITEURL
进入到Wordpress安装目录下,打开wp-config.php进行修改
//Set HTTPS as home address define('WP_HOME','https://www.xxx.com'); //Set HTTPS as siteurl define('WP_SITEURL','https://www.xxx.com'); define('FORCE_SSL_ADMIN', true); define('FORCE_SSL_LOGIN', true);
二、 LEAMP环境添加环境反向代理设置
LEAMP环境前端用Nginx,后端用Apache。如果不进行这个设置,Wordpress会显示不正常,出现网址无限循环的情况。如果只单独使用Nginx或者Apache,就不需要这个步骤。同样是打开wp-config.php进行修改。
// If WordPress is behind reverse proxy // which proxies https to http if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) || (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) { // http://wordpress.org/support/topic/wordpress-behind-reverse-proxy-1 $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST']; // http://wordpress.org/support/topic/compatibility-with-wordpress-behind-a-reverse-proxy $_SERVER['HTTPS'] = 'on'; }
本文转自黄聪博客园博客,原文链接:http://www.cnblogs.com/huangcong/p/6679146.html,如需转载请自行联系原作者