When and Where to do HTTP(S) Redirects

Where a company decides to handle the redirect from a root domain to a ‘www‘ subdomain (or vice versa) largely depends on their specific architecture, the resources they have at their disposal, and the overall complexity of their systems. Here are the two most common places where this is handled:

1. Web Server Level (like IIS, Apache, Nginx): This is often the simplest place to handle the redirect, especially for smaller systems or those with a single type of web server. This is done via server configuration files or modules, like the URL Rewrite module in IIS or mod_rewrite in Apache.

2. Load Balancer or Reverse Proxy Level (like F5, HAProxy, AWS ALB): For larger systems, especially those using multiple types of servers or those spread across multiple data centers, handling the redirect at the load balancer or reverse proxy level can provide better control and simplicity. This also offloads the redirect processing from the web servers.

As a general best practice, you want to handle the redirect as “upstream” as possible – that is, handle it at the earliest point in the request cycle. This improves performance by reducing unnecessary load on downstream servers.

Remember that no matter where you implement the redirect, you should also make sure that your DNS records are set up correctly for both the root domain and the ‘www‘ subdomain.