Solved

Redirect domain to subdomain. Show domain in address bar.

Posted on 2009-07-05
3
275 Views
Last Modified: 2012-08-13
I have a main domain: domain1.com and a subdomain: sub.domain1.com.  I have another domain: domain2.com.  I would like requests for www.domain2.com to go to sub.domain1.com, but have the browser address bar show www.domain2.com.  The .htaccess file below is close to what I want, except the address bar shows sub.domain1.com instead of www.domain2.com.  How can I fix this?
RewriteEngine On

Options +FollowSymlinks

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]

RewriteRule ^ http://sub.domain1.com[R,L]

Open in new window

0
Comment
Question by:geomouchet
  • 2
3 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 24783211
Your subdomain is not connected to your main domain (e.g. a subdirectory of it)? If that's not the case, you'll need a reverse proxy:
RewriteEngine On

Options +FollowSymlinks

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]

# requires mod_proxy et al.

RewriteRule ^(.*) http://sub.domain1.com/$1 [P]

Open in new window

0
 
LVL 1

Author Comment

by:geomouchet
ID: 24784949
caterham_www: Thanks for your help.  I'm kind of lost with this htaccess stuff.  I tried your rewriterule, but it gives a 404 error.  If it makes a difference, at my host the main domain directory is /www/www and the subdomain is /www/sub
0
 
LVL 1

Accepted Solution

by:
geomouchet earned 0 total points
ID: 25219381
This is what actually worked:
RewriteEngine On

Options +FollowSymlinks -Indexes

RewriteOptions MaxRedirects=10

RewriteBase /

RewriteCond %{HTTP_HOST} ^www.secondary_domain.* 

RewriteCond %{REQUEST_URI} !/subdirectory/

RewriteRule ^(.*)$ /subdirectory/$1

RewriteCond %{HTTP_HOST} ^secondary_domain.*

RewriteCond %{REQUEST_URI} !/subdirectory/

RewriteRule ^(.*)$ /subdirectory/$1

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now