How to create a virtual host that works with both http and https? How to create a virtual host that works with both http and https? apache apache

How to create a virtual host that works with both http and https?


So, my config now is:

Listen 443 httpListen 80NameVirtualHost *:80NameVirtualHost *:443ServerName *: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>

Not sure about SSLEngine off, but now it works. So, I add rewrite rule to redirrect from http to https in http vhost's .htaccess file:

#Redirrect from http to httpsRewriteEngine OnRewriteCond %{HTTPS} offRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]