Search code examples
apachevhosts

apache default ssl page


I have an apache website running under a specific domain with a ssl vhost activated. All works finde. If you connect to http://ip then you get the apache forbidden page, which is also fine. But if I visit https://ip I do not get get that forbidden page. It just shows the configured website I mentioned before with an SSL-Warning, because the certificate does not match the ip. The question is: What is best practice if I do not want to show my website content via https://ip, but a forbidden page instead?

The current workaround is creating another vhost for an arbitrary domain pointing on my server with an ssl vhost that is shown as default webpage for SSL-content. I configured this vhost to show the forbidden page. But I feel that there has to be a more elegant way to solve this problem.

Sorry if this is a duplicate, but I'm stuck finding solutions that do not match my actual problem.


Solution

  • Alright, we found a solution that will work perfectly for us. We will just redirect everything that does not belong to our specified domain to our main domain:

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

    Hope this helps someone else. The problem came up when a payed CMS-Theme, in this case bound to example.com, checked for the correct domain in the HTTPS header. When opening https://ip, the Theme got locked.