WORDPRESS改为https部署

Jensen WEBWORDPRESS改为https部署已关闭评论150阅读模式

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 2020.1.10
$_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 2020.1.1
yovisunhome=′https://′._SERVER['HTTP_HOST'];
yovisunsiteurl=′https://′._SERVER['HTTP_HOST'];
define('WP_HOME', $yovisunhome);
define('WP_SITEURL', $yovisunsiteurl);

3.重启httpd

service httpd restart

文章末尾固定信息

weinxin
我的微信
微信号已复制
我的微信
微信扫一扫
 
Jensen
  • 本文由 Jensen 发表于2021-07-27 15:54:35
  • 转载请务必保留本文链接:http://ivell.cn/wordpress-https/