【发布时间】:2015-05-22 13:42:23
【问题描述】:
我无法让我的 WordPress 网站在没有 www 和 https:// 而不是 http:// 的情况下初始加载。
我将 WordPress 永久链接设置为“帖子名称”,因此 URL 看起来像“https://example.com/sample-post”。我还将“WordPress地址(URL)”和“站点地址(URL)”更改为“https://example.com”。
我将此添加到 wp-config.php:
define( 'FORCE_SSL_ADMIN', true );
没有任何作用。
我所做的一项工作就是将它添加到 .htaccess 中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
</IfModule>
# 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
它最初会将我的网站加载为 www.example.com,然后在 3 秒后将其更改为 https://example.com。这似乎是一个奇怪的 hack。
我错过了什么?如何让我的网站最初使用 https://
正常加载【问题讨论】:
标签: php wordpress .htaccess url mod-rewrite