3

i have a website and a sub domain..

the main website is hosted in server A and its sub domain in server B..

main website = server A    
sub domain = server B

when i have high traffic i will redirect my main website to my sub domain.

http://main-website.com redirects to sub.main-website.com

and

http://main-website.com/post1 redirects to sub.main-website.com/post1

i am using htaccess in main website server to do this redirection...

i will have 400 - 800 requests coming every second for server A (main website server, which contains the htaccess for redirection)

actually the server cannot manage those many requests if i am hosting my website in that..

as i am using the htaccess file only in the server... will it affect server ?

HTTP500
  • 4,843

3 Answers3

2

Your server A still has to parse the request, test it against the .htaccess rules and send the redirect response. However, compared to executing a hit to your website code, I assume this would have much less impact.

Additionaly, if the redirect to the subdomain is done via 302/303, all of the subsequent hits from the same user will go to server B immediately, so every new user would create only one single hit to server A, which should be negligible.

1

With .htaccess enabled, Apache will look for .htaccess files for every request which is slower compared to just using a config file (loaded once during Apache start).

If it happens that a request reads from a lower-level directory (e.g. /myapp/file), Apache will also look for .htaccess files on higher-level directories (e.g. /myapp/.htaccess and /.htaccess).

You can read more about it from the Apache docs

user241
  • 356
  • 2
  • 3
0

As an alternative option, I assume that each server has a different global IP address? If you are using a DNS solution with Dynamic DNS support and script update support then you should be able to dynamically update the DNS based on the loading. Of course you will need to be very careful with sessions etc. to make sure that user data is correctly synchronised across both servers.

The problem with using redirects, especially 302/303 is that you will need to monitor the loading on both machines potentially leaving users in redirect loops.

zelanix
  • 111