Partial Domain Forwarding / Redirection

Hi experts,

Our website was built using Ruby on Rails, and we need to recreate it very quickly in a LAMP environment on a different server (Server B) which does not support ROR.

The site consists of a majority of content that can be recreated in static html and can be setup on
the new server in a relatively short space of time..

The site current has the following structure on Server A

www.mysite.com
-> News
-> Forum
-> Photos
-> Profiles

Our plan is to recreate a. News b. Forum c. Photos statically on the new server and migrate across the dns records to point to this new server..

What we need to happen is if the user goes to www.mysite.com or www.mysite.com/news etc it will be served from Server B however if the user goes to www.mysite.com/profiles it will be served from the OLD server (Server A) with www.mysite.com/profiles in the browser address bar..

Is this possible via domain forwarding / redirection?

Would appreciate your help urgently on this one..












moconnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdmdjCommented:
Could you setup Server B with a sub domain of ww2.mysite.com with all the folders it requires, such as ww2.mysite.com/news

When someone attempts to go to www.mysite.com/news they're automatically forwarded to ww2.mysite.com/news

You could do this with PHP or HTACCESS, PHP would be:

<?
header("Location: http://ww2.mysite.com/news");

exit;
?>

Save that as index.php in the www.mysite.com/news folder and they'll be sent to the new server automatically.

If you REALLY want to maintain the www.mysite.com/news in the location bar, you would probably have to use HTML frames, which I personally would steer clear from.
0
moconnAuthor Commented:

Thanks for your response..


Not sure if that would work entirely as we want users to be able to type in www.mysite.com/news and get the news page on Server B

People would know that they have to enter ww2.mysite.com/news to access it..
0
sdmdjCommented:
You are right in as much as they would SEE ww2.mysite.com/news in their location bar, but they will always be able to type in www.mysite.com/news and they'll always be redirected to ww2.mysite.com/news regardless.

They would never need to type ww2.mysite.com/news into their location bar, the forwarder would always take care of that.

The only other option I can think of, if you are using Apache, is you could write some mod_rewrite rules, however this is fairly complicated! I've provided a link to the Apache 1.3 manual below if you want to read more about it:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
0
WilliamFrantzCommented:
You will have to use two different domain names to distinguish between servers.  DNS does not provide routing based on sub-directories.

You could use sub-domains like this:
http://news.mysite.com
http://forum.mysite.com
http://photos.mysite.com

Each of those domains could point to different IP addresses.

If you don't want to change your URLs at all, you can use PHP includes.  Suppose the new server is www.mysite.com and the old server is old.mysite.com.  Create a file on www named news/index.php with this single line in it:

<?php include 'http://old.mysite.com/news'; ?>

Warning: Make sure PHP.ini has allow_url_fopen enabled.  Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

You will have to create a similar file for every other URL that you want to mirror from old.mysite.com to www.mysite.com.  My example just gets the default file (like 'index.html').
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.