WordPress在linux中部署https(ssl)后设置301跳转将http跳转到https

进入到根目录中找到.htaccess文件,编辑.htaccess文件写入以下规则:

  1. # BEGIN WordPress
  2. <IfModule mod_rewrite.c>
  3. RewriteEngine On
  4. RewriteCond %{HTTP:From-Https} !^on$ [NC]
  5. RewriteCond %{HTTP_HOST} ^(www.)?banwangzhan.com$ [NC]
  6. RewriteRule ^(.*)$ https://www.banwangzhan.com/$1 [R=301,L]
  7. RewriteBase /
  8. RewriteRule ^index\.php$ - [L]
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteRule . /index.php [L]
  12. </IfModule>
  13. # END WordPress
喜欢