【发布时间】:2020-08-13 16:29:36
【问题描述】:
我在我的 Google Compute Engine 托管的 WordPress 多站点安装上安装了 SSL,并且一直很难让它完全工作。现在,每个站点的主要域都正确重定向到其 https 版本,并且站点显示它们是安全的,因此它们似乎配置正确。所有链接/图像/等都使用动态 URL,因此它们也可以正常更新。
但是,如果我以 http 形式直接访问站点的子页面,它不会重定向到 https,而是显示 404 错误(APACHE 404 错误,而不是 WordPress 404 错误)。
如果我手动将 https 添加到 url 中,它会正确加载,否则只会显示 404 错误。
我已经倾注了 StackOverflow 和 StackExchange 并尝试了大约 20 种不同的解决方案,但没有一个有效。最近我尝试了以下方法:
# Redirect HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
不幸的是,它不起作用。你可以在这里看到我的意思的一个例子:
http://polararealty.com(将正确重定向到 https)
http://polararealty.com/listings/(不会重定向到 https,而是显示 404 错误)
https://polararealty.com/listings/(显示上述应重定向到的正确页面)
有人告诉我,服务器似乎根本没有提供 HTTP 页面,因此 htaccess 文件没有任何效果。我很困惑是什么原因造成的。
我使用本教程安装 SSL 是值得的:
https://onepagezen.com/free-ssl-certificate-wordpress-google-cloud-click-to-deploy/
【问题讨论】:
标签: apache .htaccess http https google-compute-engine