I would like domain1.com/customers to go to domain2 my home directory public html's folder / customers. Both domains are on different servers. In the folder on the second server/second domain we will run several test sites for our clients.Sites like domain2.com/henry/index.php. Both sites are on LAMP servers. To redirect domain one to two I could use a DNS redirect.
I do want to keep the domain domain1/directory shown in the browser address bar so I think I have to use domain masking for this.
I found this Stackoverflow thread. This is based on Mod rewrite tasks I believe. But to me that is just a standard 301 redirect. And that is not what I need here. I need masking as well.
I found a better redirect still here:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)domain1\.com [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [QSA,L,R=301]
But I still am not sure whether this would mask the final domain so constitutes url masking which I need. Reading on it at WebGUI atm. To mask the url they have this example:
# mask real url
RewriteCond %{REQUEST_URI} ^/css
RewriteRule ^(.*)$ http://www.domain.com$1 [P,L]
RewriteCond %{REQUEST_URI} ^/media
RewriteRule ^(.*)$ http://www.domain.com$1 [P,L]
RewriteCond %{REQUEST_URI} ^/uploads
RewriteRule ^(.*)$ http://www.domain.com$1 [P,L]
RewriteRule ^(.*)$ http://www.domain.com/dir/ [P,L]
The P stands for Proxy and L for last. Proxy is needed for masking as far as I understood so far. Flags explained here.
My hoster said I should probably use Apache Alias. Apache Alias does also take care of internal redirects so I guess he is right as far as making sure data on the second domain/server is loaded from the proper location. He mentions using:
<VirtualHost domain2.com:80>
…configuratie…
Alias /customers /var/www/html/customers
</VirtualHost>
Question: How do I keep domain1/directory in the browser address bar and make it load sites from domain2/directory such use domain2.com/customers/peter/idex.php /henry/index.php and so on ?