سؤال

التكوين الخاص بي هو:

Listen 443 http
NameVirtualHost *:80
NameVirtualHost *:443
ServerName *:80

<VirtualHost *:80> 
  [some non-ssl stuff]
  ServerName account.example.com
</VirtualHost>

<VirtualHost *:443> 
  [some non-ssl stuff(directory, docroot)] 
  ServerName account.example.com
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

لذلك لا يمكنني الوصول إلى إصدار HTTP من موقعي ، لكن إصدار SSL يعمل بشكل صحيح. أريد استخدام كل من VHosts و HTTP (80) و HTTPS (443) لإعادة كتابة HTTP إلى HTTPS url عبر mod_rewrite.

uname -a
Linux 3.4.62-53.42.amzn1.x86_64 GNU/Linux

httpd -v
Server version: Apache/2.2.25 (Unix)

الرجاء المساعدة لفهم ما أفعله خطأ.

هل كانت مفيدة؟

المحلول

لذا ، فإن تكوين بلدي الآن هو:

Listen 443 http
Listen 80
NameVirtualHost *:80
NameVirtualHost *:443
ServerName *:80

<VirtualHost *:443> 
  [some non-ssl stuff(directory, docroot)] 
  ServerName account.example.com
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

<VirtualHost *:80>
  SSLEngine off
  [other stuff like docroot]
</VirtualHost>

لست متأكدا SSLEngine off, ، لكنه الآن يعمل. لذلك ، أضيف قاعدة إعادة كتابة إلى إعادة تدوير من HTTP إلى HTTPS في ملف .htaccess HTTP VHOST's:

#Redirrect from http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top