简体   繁体   中英

.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 ie 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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM