Reputation: 11
I have an existing website at domain1.com, and we eventually started a new website at domain1.com/newsite. Now we'd like to give that site its own domain name but keep it at the current location, so we purchased a new domain name (domain2.com) and pointed it to domain1.com/newsite
Including this in our htaccess works perfectly for redirecting all URLs,
RewriteCond %{HTTP_HOST} ^domain2.com$ [NC]
RewriteRule ^ http://domain1.com/newsite/%{REQUEST_URI} [L,P]
But, I'd like to mask the URL in the address bar so that visitors only see domain2.com along with whatever page they're requesting in their browser. domain2.com/foo for example which would display content from domain1.com/newsite/foo
All solution I've been able to find either accomplish what I already have in place, or provide domain masking by only showing domain2.com in the address bar without anything following it.
Any help or advice would be greatly appreciated!
Upvotes: 1
Views: 194
Reputation: 21716
Use virtual hosting and alternate document roots:
<VirtualHost *:80>
DocumentRoot /www/newsite
ServerName domain2.com
# other directives
</VirtualHost>
This assumes the DocumentRoot of domain1.com is /www.
Upvotes: 0