1.确保你已经正确开启了httpd 2.4.6的https配置,并且配置了该网站的虚拟主机,如下所示:
<VirtualHost *:443>
DocumentRoot "/appvol/wordpress_blog"
ServerName robin.org.cn
ServerAlias www.robin.org.cn
AddType text/html .php
<Directory "/appvol/wordpress_blog">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/appvol/wordpress_blog"
ServerName robin.org.cn
ServerAlias www.robin.org.cn
AddType text/html .php
#对于80端口开启RUL重定向
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
<Directory "/appvol/wordpress_blog">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
2.配置wordpress站点配置文件
在* @package WordPress后面添加如下配置:
//added at 2019.1.23
$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
在
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
前面添加如下配置,如果已经存在,确保http已经修改为https:
//added at 2019.1.19
$yovisunhome = 'https://'.$_SERVER['HTTP_HOST'];
$yovisunsiteurl = 'https://'.$_SERVER['HTTP_HOST'];
define('WP_HOME', $yovisunhome);
define('WP_SITEURL', $yovisunsiteurl);
3.重启httpd
service httpd restart