AWS Wordpress HTTP到HTTPS重定向不起作用

时间:2018-06-24 09:42:06

标签: wordpress https

我在Wordpress HTTP到HTTPS重定向方面遇到问题。 目前,我使用Godaddy域设置了AWS EB应用程序。我寻求帮助HERE。但是目前,我在重定向方面遇到问题。

我已遵循此解决方案。找到了here

HTTP到HTTPS重定向

要将HTTP重定向到wordpress应用程序上的HTTPS,我在 .htaccess 的顶部添加了以下几行。

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{SERVER_PORT} 443
 RewriteRule ^(.*)$ https://example.com/$1 [R,L]
</IfModule>

此外,在MySQL设置之后,将以下行添加到 wp-config

/** force SSL on admin pages **/
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false){
    $_SERVER['HTTPS']='on'; 
}

这是我完整的.htaccess

<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{SERVER_PORT} 443
     RewriteRule ^(.*)$ https://example.com/$1 [R,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

但是它不起作用。当我转到http://example.com时,它不会重定向到https://example.com,而是在http://example.com上加载。

请帮助。

编辑

我注意到一件事,如果我尝试使用http://www.example.com而不是http://example.com,它将重定向到https://example.com,否则重定向。是什么原因呢?

0 个答案:

没有答案