2017-05-01 4 views
0

私は、ELBでAWSのhttpからhttpsへのリダイレクトを設定しました。手順は次のとおりです。ファイルの.htaccessでChromeとFireFoxでAWSのELBを使用してHttpからHttpsにリダイレクト

、以下のX-転送さ-プロトコードを入れ

<VirtualHost *:80> 
    RewriteEngine On 
    RewriteCond %{HTTP:X-Forwarded-Proto} !https 
    RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker 
    RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 
</VirtualHost> 

次に.htaccessファイルはフォルダ私のウェブサイトのindex.phpのステーの内側に置かれています。

Chrome、FireFox、Safariでテストしました。 ChromeとSafariはどちらも動作しますが、FireFoxは動作しません。

ChromeとSafariの両方で、ブラウザでwww.domainname.comを入力すると、ブラウザの変更がhttps://www.domainname.comと表示されます。 Safariと同じです。

しかし、Chromeでは、www.domainname.comを入力すると、ページにはhttp://www.domainname.comが読み込まれます。 http://www.domainname.comと入力しても、それだけでhttps://www.domainname.comに変更されます。

何が間違っている可能性がありますか?リダイレクトはまだFireFoxでは動作しませんか?

+0

はいブラウザキャッシュを数回クリアしました。 FireFoxはまだ同じです。 – batuman

+0

ブラウザは私にそれが安全でないことを表示しません。しかし、私はまだ前面にhttpsが表示されません。 – batuman

+0

私はELSからX-Forwarded-Protoを使用してリダイレクト情報を挿入するという手がかりを得て返信しました。したがって、リダイレクトの実際の実装は、インスタンスのApacheで行われる必要があります。私はどのように把握する必要があります。 – batuman

答えて

0

私は長い間この問題を解決しており、今すぐ正常に動作させることができます。 私は次のようにして分かち合っています。

(1)Create .htaccess file inside the folder same as root file index.php exists 
(2).htaccess file has 
RewriteEngine On 
RewriteCond %{HTTP:X-Forwarded-Proto} =http 
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent] 
(3)Then enable mod_rewrite, try the command line command: 
    sudo a2enmod rewrite 
(4)To make sure mod_rewrite is enabled, update /etc/apache2/apache2.conf file as 
<Directory /var/www/html> 
     Options Indexes FollowSymLinks 
     AllowOverride All 
     Require all granted 
</Directory> 
initially was 
<Directory /var/www/> 
     Options Indexes FollowSymLinks 
     AllowOverride None 
     Require all granted 
</Directory> 

Then you can setup http to https successfully 
You need to restart server as sudo service apache2 restart after update of /etc/apache2/apache2.conf 
関連する問題