7

I have multiple domains forward issue. Domains with plurals and singular e.g.:

  • example.com,
  • examples.com,
  • example.biz,
  • examples.biz

I forwarded all of them to https://examples.com and https://www.examples.com but ran into web browser warnings about someone could intercept communications as the SSL cert issued is not for the current website I visited. I have SSL cert for https://examples.com and https://www.examples.com

What is the best solution for this?

1
  • 2
    Get a multi-domain SSL certificate for the IP address performing the redirects. Each domain variation should be included in the SAN. Mar 1, 2018 at 15:33

2 Answers 2

7

Cloudflare is a free solution for redirecting your alternate domains with HTTPS support. Here are detailed instructions for setting it up:

  1. Visit Cloudflare
  2. Create an account and verify your email address
  3. Use the "add a site" feature to add your alternate domain under their free plan. If you are creating an account, it should ask you to do this as a step of the account creation process.
  4. Set up your DNS at Cloudflare
    • Cloudflare will import your DNS from your current web host
    • Keep all TXT, SOA, and MX records as well as any subdomains that you don't want cloudflare to redirect.
    • Ensure that records you do want cloudflare to redirect are "Proxied". Click on the icon in the "Proxy status" column to change whether or not they are proxied. Proxied records will be handled by Cloudflare's web servers.
    • Since we will later add a redirect rule, the IP address you enter for proxied A records doesn't actually matter, no traffic will ever go to it.
    • Make sure you have a proxed A record for the domain apex (@)
    • I also have a wildcard subdomain proxied A record (*) so that all subdomains (including www) get redirected.
  5. Go to your DNS registrar and update your nameserver (NS) records to be the values that Cloudflare gives you.
  6. Cloudflare will try to verify these for you. Don't worry if that doesn't work right away, the verification could take a few hours and Cloudflare will retry it for you.
  7. Go to "Page Rules" and add the following rule to do the redirect.
    • URL matches: *example.com/* Where you use your alternate domain in place of example.com. The first * is a wildcard that matches any subdomain. The second * is a wildcard that matches any path. This single rule should match every request to the domain and its wildcard subdomains.
    • Pick a setting: Forwarding URL
    • Select status code: 301 - Permanent Redirect
    • Enter destination URL: https://example.org/$2 where you use your main domain in place of example.org. The $2 is the URL path captured from the second glob of the URL match. Without $2, all the requests for deep pages would redirect to the home page. This rule strips the subdomains. If desired you could use https://$1example.org/$2 to preserve the captured subdomain as well.
    • Save the page rule.

It could take hours for everything to start working.

  • Your new NS records need to propagate through DNS. This should take a couple hours, but worst case could take a few days.
  • Cloudflare need to update their servers with your rules. This should take a few minutes.
  • Cloudflare needs to create a SSL certificate for your HTTPS requests. This should take a couple hours.

If you are impatient to test things, you can start testing on the command line.

  • See if your NS records have updated: dig NS example.com where you use your alternate domain in place of example.com. Look for the cloudflare NS records.
  • See what server Cloudflare is using for your site: dig @xx.ns.cloudflare.com example.com where you use one of the actual NS records that Cloudflare gave you instead of xx and again your alternate domain. Look for an A record with an IP address that you can use see if the redirects are working on Cloudflare's servers.
  • See if Cloudflare is serving redirects: curl --resolve example.com:80:X.X.X.X --head http://example.com/ where X.X.X.X is one of the IP addresses from the previous step and you use your alternate domain in place of example.com. Look for a Location: header with the redirect destination. You can repeat this step with other URLs such as http://www.example.com/, http://foo.example.com/, http://example.com/path and https://example.com/. Keep in mind it may take a couple hours for the HTTPS redirects to start working.

Cloudflare lets you add many additional alternate domains to your Cloudflare account and set them up the same way. Each of your alternate domains can use its own free plan.

1
  • I looked into numerous possible solutions to resolve this issue, including messing about with certificates and server configs, Some just didn't work out (GoDaddy domain forwarding). This approach was by far the smoothest solution and it works! May 30 at 8:30
-2

Well, at first sight, it seems like you have issued an SSL certificate which you have installed in another domain and this will certainly trigger these warnings.

And you are not telling us which method you used to redirect the domains, there are ways to redirect the domains directly from your DNS panels, or with .htaccess files, or by using a Meta Command in the MySQL DB, or even by making a .php script for the redirection.

My opinion is that you should use

  1. DNS redirect
  2. .htaccess 301 redirects.

In case A you just add a redirect to the domains you want from within the DNS panel at your Domain registrar. This is the simplest and easiest solution.

Then you check again your SSL certificates and after that, you had to make sure that you have purchased the SSL for the right domain, i suggest to install it again.

And that's it.

Now if you want to use the redirect with the .htaccess file you have to NOT redirect your domains from the DNS panel of your registrar to the other domain, but point them in your webserver, in which you will have created the necessary webspace for their hosting, and then you will edit the .htaccess file.

Then you will open the root folder, in the webserver, in the webspace of the domain that is to be redirected, and If no .htaccess exists in your root folder currently, you can create one using an application like Notepad (or a similar plain text application).

The code for the file is contained in the next step. Make sure that when you save your .htaccess file it begins with a “.” Note that this file has no tail extension (e.g. “.com” or “.txt”)

Paste the following code into the .htaccess text file: .redirect 301 /old/oldURL.com http://www.newURL.com In the code, oldURL.com represents the landing page address your visitors will need to be redirected from while http://www.newURL.com represents the address you'd like your visitors redirected to. There should be exactly one blank space between oldURL.com and http:// Don't add http://www to the (old) URL in the first part of the code!

The code "301" is most commonly used on redirected sites and means "moved permanently".

5
  • 2
    There is no such thing as a "DNS redirect" DNS can only point a domain name to an IP address. Even a CNAME record only says "use the same IP address as this other domain name", but it can't redirect. Mar 1, 2018 at 10:33
  • 1
    When you say "check your SSL certificates" what should they check for? It sounds to me like they need 3 additional domains added to their certificate with 3 additional www variants. How should they do that? Mar 1, 2018 at 10:35
  • @StephenOstermiller well, you are right, i was meaning URL redirect but still if you/he do/does a Google search with the term "DNS redirect" you get results about URL redirect. So, when developers say "Do a DNS redirect they mean do a URL redirect by adding the IP in which you want to get redirected to". Syntactically your comment is right. But still the meaning is exactly the same. As for the SSL's. They have to check for which domain name they have purchased the SSL for and use it for that domain. Or simply add 3 additional "www" as you say, if their SSL service provider offer this..
    – Theodor_D.
    Mar 5, 2018 at 13:53
  • and what for exactly you gave me a minus for my reply?? isn't this a reply which explains to a new user what he has to do to solve his problem??
    – Theodor_D.
    Mar 5, 2018 at 13:58
  • 2
    I left two comments explaining my down vote. I think their problem is mostly that their security certificate doesn't cover the alternate domain names. You should edit your question to remove the domain redirect and add more about expanding certificates Mar 5, 2018 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.