I have a centos server, but I am having some issue regarding port 443 and ssl. my problem is that all domain on my server are accessible from HTTPS port.

like when I visit a domain on my server from HTTPS, which do not have ssl, then it shows default host page (default apache page)

I want only domain which I specified should only use ssl port.

I have certificate for a domain, and I have added virtual host like this:

<VirtualHost *:80 *:443>
     ServerName domain.com
     ServerAlias www.domain.com
     ErrorLog ...
     CustomLog ...

and other certificate file locations are specified in /etc/httpd/conf.d/ss.conf

I also tried creating 2 separate with port 80 and 443, but still it does not help in my case. still if i visit other domain with HTTPS, i see default Apache page.

Thanks for help

closed as off-topic by MadHatter, Iain, mdpc, Jenny D, Ward Jun 5 '14 at 4:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – MadHatter, Iain, Ward
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    you should use two <VirtualHost> blocks. one for *:80 an done for *:443 and configure your ssl only in th *:443 block. – Dodge Jun 3 '14 at 6:48
  • Tried that too, but same thing happen – user007 Jun 3 '14 at 6:52
  • possible duplicate of Two domains (when SSL) on same directory – Jenny D Jun 4 '14 at 8:28
  • No its not duplicate, i have different issue – user007 Jun 4 '14 at 8:30

you might want to try this:

<VirtualHost *:80>
  ServerName www.domain.com
  ServerAlias domain.com

  // non ssl config

  RewriteEngine on
  RewriteRule ^/(.*)$ https://www.domain.com/$1 [L,R=301]
<VirtualHost *:443>
  ServerName www.domain.com
  ServerAlias domain.com

  // your ssl configuration etc

  RewriteEngine on
  RewriteCond %{HTTP_HOST} !^www.domain.com
  RewriteRule ^/(.*)$ https://www.domain.com/$1 [L,R=301]

this should redirect all requests to www.domain.com no matter what other domain the user used. if you want to preffer domain.com over www.domain.com move the www. from ServerName and the Rewrite statements and add it to the ServerAlias.

the rewrite in *:80 redirects your www.domain.com to the https site and the rewrite in *:443 ensures that your request goes to https://www.domaincom

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