WORDPRESS改为https部署

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

如果您喜欢我,可以通过微信请我喝果汁。

如果有疑问,可以留言或者发邮件给我 lhh_nj@163.com
原文地址:https://www.cnblogs.com/lihuanhuan/p/10612104.html