Is it possible to serve websites on the same host with the same apache some in https and others in simple http?

If it is possible, can anyone give me a hint to make it works?

Thanks in advance!!


In Apache use the config:

You can use multiple blocks for different website names so that they listen on HTTP or HTTPS which ever the port is required

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 *:80>
  SSLEngine off
  [other stuff like docroot]

For single website to work on both the ports, Add rewrite rule to redirrect from http to https in http vhost's .htaccess file:

#Redirrect from http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Done. You will be able to use both HTTP and HTTPS now.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.