?
Solved

Partial Domain Forwarding / Redirection

Posted on 2006-04-05
4
Medium Priority
?
335 Views
Last Modified: 2012-06-27
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..












0
Comment
Question by:moconn
  • 2
4 Comments
 
LVL 2

Expert Comment

by:sdmdj
ID: 16382789
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
 

Author Comment

by:moconn
ID: 16383408

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
 
LVL 2

Expert Comment

by:sdmdj
ID: 16383750
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
 
LVL 6

Accepted Solution

by:
WilliamFrantz earned 2000 total points
ID: 16386033
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question