0

I am trying to fix a setup where people accessed a site via https://subdomain but we have a proper SSL cert for https://subdomain.domain.tld.

I am trying to force redirect to https://subdomain.domain.tld when people navigate to the old URL.

I've tried all sort of variations to no avail. Currently my thinking was something like below:

Note: This seems to work for http --> https but not http(S).

<VirtualHost *:80>
  ServerName subdomain.domain.tld
  ServerAlias subdomain
  RewriteEngine On
  RewriteRule ^/?(.*) https://subdomain.domain.tld:443/$1 [R,L]
</VirtualHost>

<VirtualHost *:443>
  ServerName subdomain
  Redirect https://subdomain  https://subdomain.domain.tld:443/
</VirtualHost>

<VirtualHost *:443>
  ServerName subdomain.domain.tld

  ....
</VirtualHost>
1
  • 1
    To redirect everything use Redirect / https://subdomain.domain.tld/ (HTTP 302) or Redirect permanent / https://subdomain.domain.tld/ (HTTP 301). You don't need to add the port number :443 in both examples as this is the default https port. You could also change the RewriteRule to a Redirect in your first vhost and remove RewriteEngine On.
    – Freddy
    Commented Feb 24, 2020 at 19:59

1 Answer 1

0

Basically, you NEED to have the SSL for both sites if you want to redirect https --> https. I was able to redirect using a separate virtual-host and the old SSL cert which was self-signed to the new public one, but any users without the CA for the self-signed cert will not get redirected.

You must log in to answer this question.

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