1

How do I set it up such that https://anything.example.com redirects to https://example.com properly?

My current setup goes like this:

http://example.com --> https://example.com
http://subdomain.example.com --> https://example.com

I have a CNAME record with my webhost that points *.example.com to example.com.

The problem is that I don't have a wildcard certificate, so when users try to go to https://subdomain.example.com, they are met with this pleasant page.

Here's my configuration file:

<VirtualHost *:80>
    ServerName example.com/
    Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    SSLEngine on
    SSLCertificateFile /home/ssl.crt
    SSLCertificateKeyFile /home/ssl.key
    SSLCACertificateFile /home/intermediate.crt

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    Options -Indexes
</Directory>

I'm running Apache2 on Ubuntu 14.04. I'm not using an .htaccess file.

1 Answer 1

2

This is not possible without a wildcard certificate or a certificate for the subdomain. You could create a cert for each of your subdomains using Let's Encrypt though (assuming cost is the issue).

2
  • Ah, I was afraid that might be the case. Thanks for the quick response. I'm guessing there's no way to have it throw an error gracefully or have Apache refuse the request either?
    – Nate
    Jun 10, 2016 at 19:58
  • Nope. Is there a reason you can't create SSL certificates for each of your subdomains?
    – Jedi
    Jun 10, 2016 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .