0

Our company has recently changed the domain name for one of our produce websites, and wants all traffic from the old to be redirected to the new.

Right now that comes up with a privacy error as the ssl is on www.newdomain.com instead of www.olddomain.com.

Is there anyway to redirect www.olddomain.com to www.newdomain.com without it reporting this error? My suspicion is that I will need to install an SSL on the old domain as well but would like to avoid this if possible.

I have so far attempted to do this via the vhost and/or htaccess, and aliasing the old domain in the new domains conf file, eg:

RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [L,R=301,NC]
  • 1
    If the question has already the answer, why asking it here? We are not able to perform miracles. Any SSL site has to go the right certificate. At most the redirection can be done in HTTP, but that wont solve any dangling links in https that may be clicked. – Rui F Ribeiro Apr 5 at 10:36
  • I am quite new to this, and struggled to find an answer to this scenario. I suspected the old domain also needed an SSL but was unsure if it was just something I was doing wrong. Thanks. – DaChMo Apr 6 at 12:28
0

You need an SSL certificate for both domains. In order to redirect from one to the other you first need a certificate for olddomain.com and www.olddomain.com so that browsers will accept the redirect instruction. You then need a certificate on your www.newdomain.com to host the new domain.

So you would setup a virtual host for the old domain which only redirects to the new one.

See apache Redirect.

<VirtualHost *:443>
    ServerName olddomain.com

    Redirect permanent / https://www.newdomain.com/

    SSLEngine on

    SSLCertificateFile      /path/to/olddomain.com/cert.pem
    SSLCertificateKeyFile   /path/to/olddomain.com/privkey.pem
    SSLCertificateChainFile /path/to/olddomain.com/chain.pem

</VirtualHost>

<VirtualHost *:443>
    ServerName www.newdomain.com

    DocumentRoot /var/www/html

    SSLEngine on

    SSLCertificateFile      /path/to/www.newdomain.com/cert.pem
    SSLCertificateKeyFile   /path/to/www.newdomain.com/privkey.pem
    SSLCertificateChainFile /path/to/www.newdomain.com/chain.pem

</VirtualHost>
  • Thanks, this was really helpful and the issue is now resolved. I'm still learning at this and don't really have anywhere to ask other than 'the internet'. Thanks again – DaChMo Apr 6 at 12:29

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.