7

I've made a new website for a client who has an intranet integrated into their old website.

The new website is currently on a different server, but when the domain A records point to the new server, the old site (and intranet) will obviously not be accessible, but I need to keep their intranet active. The path to their intranet is: abc.com/intranet

Is there a way to have URL path direct to the old server? For example:

abc.com - new website loads on new server

abc.com/intranet - old website loads on older server

If it's not possible, I suppose I'm looking at creating a sub-domain on abc.com for the intranet. Any thoughts are appreciated.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
user2992605
  • 73
  • 1
  • 3
  • I added an answer, but I am not 100% clear on rereading your question exactly what the goal is. You definitely don’t need a subdomain. Can you clearly differentiate & more succinctly explain your question? – Giacomo1968 Nov 14 '13 at 15:12

2 Answers2

2

You need to use an Apache RewriteRule using mod_rewrite. This can be placed in an .htaccess file on your server’s root or it can be placed directly into your Apache config file.

If you want to redirect example.com to example.com/intranet, then this is the Apache RewriteRule that should work for your needs:

RewriteEngine on
RewriteRule ^(.*)$ /intranet [L,R=301]

This will grab any URL on the site this RewriteRule is placed on & redirect them to /intranet. That /intranet can also be a full URL such as this example below:

RewriteEngine on
RewriteRule ^(.*)$ http://example.com/intranet [L,R=301]

EDIT: Upon rereading your question, I am not 100% sure the answer above works for you as-is. So I think if you are describing how to point one URL path from one server to another, you would do this. This gets placed on the new server:

RewriteEngine on
RewriteRule ^/intranet(.*)$ http://old_example.com/intranet [L,R=301]

That would grab any URL coming from new_example.com/intranet and redirect it to old_example.com/intranet.

ANOTHER EDIT: Since the original poster indicates the server will have the IP fully changed, then a subdomain for the old server is the best way to go. You can’t redirect content on one domain the way you describe if you switch the domains fully to different IP. Both servers need to be active with an active—but different—domain name for what you want to happen.

jerry
  • 2,581
  • 1
  • 21
  • 32
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • Thanks for the input. To clarify a bit more. Each server has it's own public IP. On abc.com, the public IP for the A record points to the older server. However, when I want to go live with the new site, I will change the A record for abc.com to the new IP/server. This means that no one will be able to access the older server's intranet by going to abc.com/intranet. I'm trying to find a way to make a redirect on the new server so that if someone wants to access the intranet, they are then directed to the old server. I can't see there is a way, but maybe you know a trick. – user2992605 Nov 14 '13 at 17:04
  • Okay, if that’s the case, then a subdomain for the old server is the best way to go. You can’t redirect content on one domain the way you describe if you switch the domains fully to different IP. Both servers need to be active with an active—but different—domain name for what you want to happen. – Giacomo1968 Nov 14 '13 at 17:47
  • Subdomain is the route I will go. Thanks. – user2992605 Nov 14 '13 at 18:27
1

abc.com/intranet is a path in the virtual file system exposed by your web server, so is not possible to serve the content from different web server. You have 2 options here.

  1. Put a reverse proxy in front of both servers and get the content from server A or B based on the original client request.

  2. As you said, create a subdomain and also redirect /intranet to the new subdomain.

Hope this help!

Babblo
  • 794
  • 5
  • 17