domainA.com/folder1/folder2/... to domainB.com/folder1/folde

Using a single web hosting account to host multiple sites

domainA.com/folder1/folder2/... to domainB.com/folder1/folde

Postby jimbo123 » Tue Nov 13, 2007 3:38 am

Hi there,

I just want to rewrite the domain part of a url and leave everything else the same. I haven't been able to find an example of this out there and I was wondering if anybody could help?

just to be clear, I'd like to rewrite:

http://domainA.com/etc/etc/etc... to
http://domainB.com/etc/etc/etc...

It doesn't look like it's that hard but I just can't make it work :(

any help would totally kick ass!

jimbo
jimbo123
 
Posts: 2
Joined: Tue Nov 13, 2007 3:31 am

Postby richardk » Tue Nov 13, 2007 2:03 pm

If the domains are on a different server and you want the URL to stay the same you'll need mod_proxy too. Try the following in domainA.com's document root
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(etc/etc/etc(/.*)?)$ http://www.domainB.com/$1 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jimbo123 » Tue Nov 13, 2007 11:51 pm

Thanks for your help Richard! It wasn't exactly what I needed but it gave me a few ideas.

For those who are interested, I ended up solving the problem like so:

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domainA\.com$ [NC]
RewriteRule ^(.*)$ http://domainB.com/$1 [R=301,L]


This will replace domainA.com with domainB.com and keep the following directory structure exactly the same. There's probably better ways to do this, but I had some pretty wierd requirements eg. rewrite http://domainA.com but not http://www.domainA.com (otherwise I could have used a domain alias)
jimbo123
 
Posts: 2
Joined: Tue Nov 13, 2007 3:31 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 26 guests

cron