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.

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).

  • 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 '16 at 19:58
  • Nope. Is there a reason you can't create SSL certificates for each of your subdomains? – Jedi Jun 10 '16 at 20:00

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.