Rewrite subfolder to subdomain with Apache htaccess

.htaccessapache-2.2mod-rewritesubdomain

Here's the situation:

I recently re-structured my website at www.pixelscrapper.com. I still have the old legacy website at legacy.pixelscrapper.com (hosted on the same server). Is it possible to use an Apache htaccess rewrite rule to make my legacy content appear available under a subdirectory on my new site?

In other words:
I want to be able to go to www.pixelscrapper.com/legacy/some-folder/some-item and see the content which is actually located at legacy.pixelscrapper.com/some-folder/some-item.

Have been searching around without much success. I thought something like the following might do the trick, but maybe I'm way off?

RewriteCond %{HTTP_HOST} ^pixelscrapper.com$
RewriteRule ^/legacy/?$ http://legacy.pixelscrapper.com/ [R=301,L]

Best Answer

It turns out that the way to achieve what I was after is to set up a reverse proxy using Apache's mod_proxy... which is actually pretty easy to do. There's a good tutorial on this at http://www.apachetutor.org/admin/reverseproxies

Related Topic