PDA

View Full Version : httaccess redirect one subdomain to another



jonshutt
22 Sep 2009, 08:49 PM
Hi there, I'm working on a new version of a site, and i've set it all up at
test.mysite.com

what I want to do, is create an .htaccess code so that poeple can view the site by going to
www2.mysite.com

then later, I wanted to do the same thing, and have it so people at www.mysite.com are actually being shown pages from test.mysite.com

Sounds a bit confusing, but the site included many videos, and doing a redirect will save me from uploading and shifting hundreds and hundreds of MB around on the website

Here's what I have so far:



RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} www2.mysite.org.nz [NC]
RewriteRule ^(.*)$ http://test.mysite.org.nz/$1 [L]


This works, in that if you go to www2.mysite.org.nz it redirects to http://test.mysite.org.nz, but it's changing the URL the viewer sees. I don't want this, I want the viewer to think they're still at the www2 domain.

Help appreciated.

Jon

Alan
23 Sep 2009, 12:09 PM
I wouldn't do this with htaccess. I would create canonical names (cname) records with your domain registrar to do this. Makes things much handier on you. Who are your domain names registered with? If i'm familiar with them I may be able to provide you with instructions or a link to some instructions.

Your logic seems to be flawed. You are rewriting www2.mysite.org.nz to test.mysite.org.nz. What you should be doing is rewriting test to www2. A cname is still the best way.