Forum Moderators: phranque

Message Too Old, No Replies

Rewrite subdirectory to a different domain

         

akaCT

10:35 pm on Dec 8, 2008 (gmt 0)

10+ Year Member



Hello,

I have spent quite a bit of time trying to find a solution to what I am trying to do without any luck. My client's old ASP site was moved to a new domain, and was replaced with a drupal (PHP) site.

I am trying to keep their old site within the old domain, but since their server does not support ASP, I need to setup some rewrite rules to point to the new domain, and redirect the old indexed links to the subdirectory.

www.site1.com was moved to www.site2.com

Old Indexed URL
[site1.com...]
is now
[site2.com...]

but I would like to rewrite it to
[site1.com...]

I started doing this buy redirecting all the ASP files to the subdirectory:

RewriteEngine On
RewriteRule (.*)\.asp$ old/$1.asp$ [L,R=301]

I am just not sure how to then send the requests to the new domain properly so the the URL stays on the old domain in order to handle the old URLs

Thank you in advance for your help!

g1smd

12:35 am on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The problem is, if you should do such a rewrite is that the content will be available at two URLs, the old one and the new one.

Somehow you would need to redirect requests for the new URL so that they go and ask for the old URL. That bit is easy, except that the rewrite will be coming at the server for content and how is the server supposed to know that now the content should be served instead of the redirect? Since the content is on a different server that's a tall order; so this cannot be an internal rewrite at all.

Additionally, it is the links on the pages that define the URLs, so the content on those pages needs to be altered such that the links a user would click on do contain the exact URL format that you want the user to see and which you want to be indexed by search engines.

I am guessing that you would need to set up some sort of proxy system, but that is very dangerous to leave open and pointing at the web. All URL requests that pass through it MUST be scrutinised and everything non-valid rejected.

It might be better to let this one go and redirect all the old URLs to the new URLs, which will also pass on a good proportion of the PageRank to the new URLs.

jdMorgan

4:31 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The kind of proxy envisioned here is a reverse proxy, and is not subject to the security problems of an open forward proxy. Just make sure that only a reverse proxy is configured, and you should have no problems.

Reverse proxies can be explicitly configured, or you can simply use the [P] flag in mod_rewrite if you're already using it for related functions.

Jim