setting up redirect rules in dns

How Google and Microsoft Handle Redirects

So how do Google/Microsoft-like companies handle the redirects we see and use on a daily basis?

The most notable one I can remember was Perplexity.in → redirecting users to Gemini. From a technical standpoint, how do you redirect to a completely separate DNS zone without any control over that zone? + How are TLS certs served in such a way?

Google’s domain resolves securely; parameters remain intact; browsers show no warnings.
All common HTTP request methods, such as GET, POST, DELETE, and PUT, can function correctly through proper redirection. However, to ensure that methods other than GET (such as POST, PUT, or DELETE) are preserved during a redirect, it is necessary to use HTTP status codes 307 (Temporary Redirect) or 308 (Permanent Redirect). These status codes instruct clients to repeat the original request method and body at the new location, thereby maintaining the integrity of the operation.

So how are they served? How is HTTPS/TLS handled? How do search engines handle these redirects, and how do they know that a domain is valid or an alternate destination for the original domain?

Don’t we need to tell the server, “Hey, this is your domain,” and store an A, AAAA, or CNAME record for it? How does the server know that this is a valid domain?

So here comes the role of your DNS provider and the way they handle redirections.

Setting up redirection via a DNS provider is straightforward: you point your subdomain to a local server range Cloudflare, for example, suggests using 192.0.2.1 paired with their proxy—and then create a rule within the provider’s dashboard to redirect all requests to the target domain.

When a user visits the subdomain, the request is routed to the local server, which then triggers the redirect to the destination. Note that this must be done using a subdomain because CNAME records cannot be assigned to an apex domain. Consequently, you can only redirect subdomains, such as “www” or any other custom prefix within that zone.

Types of redirections

google suggests some codes for redirections like 30* series.

301 Moved Permanently

302 Found

303 See Other

304 Not Modified

305 Use Proxy

306 Unused

307 Temporary Redirect

308 Permanent Redirect

This ensures that search engines understand how to handle the redirection and how to process the old URL.

The approach is straightforward: configure your DNS records to point to the DNS server itself, then establish a rule with your DNS provider to redirect all requests to the target domain. Consequently, when a user visits your subdomain, the request is handled by the provider’s local server, which then issues a redirect to the target destination.

Cloudflare suggests utilizing their proxy feature to route requests through their servers, allowing them to handle redirections more effectively. I previously implemented a similar setup using freedns.afraid.org via their “web forward” feature, which successfully redirected traffic but only supported HTTP no HTTPS. In contrast, Cloudflare routes traffic through their extensive proxy network, they can issue TLS certificates and serve content securely over HTTPS.

Subscribe on GitHub