Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Redirect domain to subdomain. Show domain in address bar.

Posted on 2009-07-05
3
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

618 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