【发布时间】:2020-01-24 21:53:14
【问题描述】:
在我的 wordpress 网站上的普通链接上,用户总是得到 https。但是,当用户键入一些不存在的页面时,我的网站可以同时使用 http 和 https。
例如:
访问者在 mypage.com/non-existing-page 中输入,他得到 404.php 页面模板,但是 404.php 页面模板可以通过 http 和 https 访问。
我想要做的是将http://mypage.com/non-existing-page 重定向到https://mypage.com/non-existing-page。
我的 htaccess 文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
【问题讨论】: