Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

I have several domains under the same server, but my https certificated only works for one of them.

  1. I need to force https for: mydomain1.com
  2. All other domains (mydomain2.com, mydomain3.com ...) must use http.

I know it must be a simple rule, but I wasn't able to figure it out.

share|improve this question

marked as duplicate by Lucas Kauffman, RolandoMySQLDBA, mgorven, mdpc, Ward Feb 6 '13 at 4:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 2 down vote accepted

Just use virtual hosts : http://httpd.apache.org/docs/current/vhosts/name-based.html

But they require to be specified inside the server configuration (can't do it inside .htaccess)

<VirtualHost *:443>
    ServerName mydomain1.com
    DocumentRoot /www/mydomain1
    SSLEngine on
    SSLCertificateFile /usr/local/apache2/conf/ssl.crt/server.crt 
    SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server.key
</VirtualHost>

<VirtualHost *:80>
    ServerName mydomain2.com
    DocumentRoot /www/mydomain2
</VirtualHost>

<VirtualHost *:80>
    ServerName mydomain3.com
    DocumentRoot /www/mydomain3
</VirtualHost>
share|improve this answer
    
I don't have access to it. I was trying to find a workaround using htaccess, but it seems that I will have to request this to the server admin. –  Acacio Feb 5 '13 at 15:03
    
All theses options are security sensitive and so are limited to server config : httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslengine Context: server config, virtual host –  Cerber Feb 5 '13 at 15:09

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