MutantTurtlez
MutantTurtlez

Reputation: 61

.htaccess Mask Domain and hide url

I am trying to get a subdomain to show to contents of another domain, with the ability to go to any area of the other domain i.e. all directories

So for example I would like my client to go to "sub.domain-one.com" or more specifically "sub.exampledomain.com/client_name". I would like this to then show the content of "domain-two.com", my development server, without the client knowing.

I would also if possible like to keep the base domain of "sub.domain-one.com" to stay on my live server so that I can keep a index.php on that server. But this is only an extra wish :)

My current code is

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !^(sub.)?domain-one.com/$1
RewriteCond %{HTTP_HOST} ^(sub.)?domain-one.com
RewriteRule ^(.*) http://domain-two.com/$1 [P,NC]

This code seems to work to an extent (it will let me go to sub.domain-one.com but if I go to sub.domain-one.com/client_name it will redirect my browser url to domain-two.com/client_name But I need it hidden :(

Thanks heaps in advanced

James

Upvotes: 1

Views: 1339

Answers (1)

Jon Lin
Jon Lin

Reputation: 143966

You need to use a ProxyPassReverse in order to rewrite redirects from the proxied site to the site that you are proxying from. Unfortunately, you can't do this in an htaccess file. In the server/vhost config, you'll need to create a virtual host for "sub.domtain-one.com"/"domain-one.com", then use ProxyPass:

ProxyPass / http://domain-two.com/ 
ProxyPassReverse / http://domain-two.com/

Upvotes: 1

Related Questions