-3

I own, say, 100 domains. I want to add redirect for each of them to a new domain. And not only to a domain, but a custom query string. For instance

domain1.example/url1 -> domain11.example/url2
domain2.example/url1/url4 -> domain15.example/fdsafds/url33/url555

# and so on......., 100 domains with 100+ URLs each

All the original URLs and the new ones are known beforehand. And there're hundreds of URLs for each domain.

Requirement: there has to be an intermediate "domain-redirector" via which the domains will be redirected, and that'll do all the job:

domain1.example/url1 -> my_redirector.example/url1 -> domain11.example/url2
domain2.example/url1/url4 -> my_redirector.example/url1/url4 -> domain15.example/fdsafds/url33/url555

# and so on.......

This way I'd create A record for each of the domains pointing to my_redirector.example. And at my_redirector.example I'd be able to extract a) original query string from the URL b) original domain

Note that it needs to work with both http and https.

Question 1: will original domain and URL or query path be accessible at my_redirector.example?

Question 2: will I have to create a SSL certificate for each of the original domains domain1-domain100 at my_redirector.example, in order to be able to redirect https requests?

P.S. I'm a developer, therefore I'm capable of writting a custom utility to facilitate redirects at my_redirector.example

0

2 Answers 2

2

It is impossible to redirect HTTPS without a certificate. You cannot redirect with via DNS alone. Even a CNAME record, which is a type of alias, is not a redirect. A CNAME simply says that all requests go to the same IP address as the specified domain name. It is up to the server how to handle those requests. It is the job of the web server to issue redirects. To be able to issue a redirect for a HTTPS URL, the web server needs a valid SSL certificate to have negotiated the encryption in order to be able to issue a redirect.

I now recommend hosting your alternate domains with CloudFlare to do redirects.

  • CloudFlare has domain redirect functionality.
  • CloudFlare uses custom "page rules" with wildcards to be able to customize the redirect path.
  • CloudFlare is a certificate authority and issues its own valid SSL certificates.
  • CloudFlare will redirect domains with HTTPS under its free tier of service. Because each domain you host with CloudFlare gets its own service tier, you can redirect unlimited domains using CloudFlare.

The biggest problem with CloudFlare is that setting up the redirects is an 8 step process. They are designed to be a CDN an their interface is geared towards that. Setting up redirects isn't as straightforwards as with other forwarding services. See the complete instructions here.

Using a custom query string on CloudFlare is possible. You need a "page rule" for each one. The basic redirect takes one page rule. The free tier has two other page rules available. If you need more rules to support your path changes, you would have to sign up for paid plans. Alternately, you could set up CloudFlare to redirect to a custom directory on your main site which then redirects to where you want it. Then you could use your main domain hosting for all the redirect rules you need.

domain1.example/url1 -> domain15.example/domain1/url1 -> domain15.example/fdsafds/url33/url555
0
0

Stephen is correct in saying you MUST have a SSL certificate to redirect an HTTPS request. But you don't need a certificate for each site. If they are all in the same zone ("example" in your question - but next time, use "example.com" to avoid confusion) then you can use a wildcard certificate. Commercial CAs will charge you extra for this (but a lot less than buying 100 certificates). In the case of LetsEncrypt, wildcard certificates are only available using a DNS-01 challenge (not HTTP-01).

Both nginx and Apache will let you configure wildcard and explicit vhosts side by side (the explicit entries will be matched first).

Adding another host in the middle means you need to execute 2 redirects which is BAD and UNNECESSARY.

Your Answer

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

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