One website from different hosting servers

Started by albert_Cage, Jan 04, 2023, 12:58 AM

Previous topic - Next topic

albert_CageTopic starter

Can we arrange users based on their user agent and redirect some to hosting 1 and others to hosting 2, similar to a tds operating at the DNS level?

There are ways to do this using a CDN, but it might not be the best solution. It's worth exploring other options.


The user agent is not identifiable at the DNS level, but it is available in the HTTP request. To analyze the user agent, you'll need either a proxy (such as nginx) or a web server that allows for redirecting to another domain name.

Nginx can also be used to balance the load between hosting providers, which can be a useful option for managing traffic effectively. By configuring nginx to route users based on their user agent, you can ensure that requests are sent to the appropriate hosting provider for the best performance.


There are many ways to implement this sort of redirect, but one possible solution is as follows:

1. Host the DNS zone for the site.
2. Set up the A-record for your main website (e.g. on Hosting A, and create a new subdomain (e.g. on Hosting B.
3. On Hosting A, use .htaccess to configure redirects based on the user agent:
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^(.*)$$1 [L,R=301]

This configuration will ensure that users accessing the site using the Opera browser will be automatically redirected to the mobile version of the site hosted on Hosting B.

It's important to note that there are many other options for accomplishing this redirect, and the specific approach you choose will depend on your technical setup and requirements.


Hi there! A CDN service would be a great fit for your needs. One free and highly recommended option is Cloudflare, which can help to improve the speed of your websites.

To fully benefit from Cloudflare's features, it's recommended to use their Pro or higher pricing plan. This will give you access to additional optimization tools and allow you to fine-tune your settings for maximum performance.

In addition to Cloudflare, there are many other CDN providers available, each with their own strengths and weaknesses. It's worth doing some research to find the best solution for your specific needs and budget.