Is it possible to url to mask a domain name with another using mod_rewrite?

Here is the script -

I have a website where customer sites work under mine.

So, as an example, my domain is www.mainsite.com , and the customer’s website will be www.customer1.com ---, but when someone goes to customer1.com, the index.html file will redirect them to my website in www.mainsite.com/customers/index.jsp?number=1000 ,

Example index.html redirecting to my website:

 <html> <head> <META HTTP-EQUIV=REFRESH CONTENT="0;URL=http://www.mainsite.com/customers/index.jsp?number1000"> </head> </html> 

Is it possible to add the rewrite directive using mod_rewrite, which will accept the client’s domain, for example www.customer1.com , and not only redirect it to my site with a variable called “number” , but also mask the rest of the pages available after that?

So, to someone who was browsing the site, they were “still” at customer1.com and instead of seeing mainsite.com ?


Edit

The client’s website / domain is hosted on the same virtual points as on my own website. My site is built on JSP pages.


+4
source share
2 answers

Do not use mod_rewrite , but there mod_proxy that does what you want (you need to enable and load the module, it is not included in the default configuration):

 <VirtualHost *:80> ServerName yoursite.example.com ProxyPass / http://maskedsite.example.net/ ProxyPassReverse / http://maskedsite.example.net/ </VirtualHost> 

Please note: 1) this means that all "masked" traffic appears from your host (instead of the user's host), and 2) any download to the masked host will go through yours.

See this for more details: http://www.apachetutor.org/admin/reverseproxies

+2
source

Why aren't you using < jsp: forward > instead of mod_rewrite?

+1
source

All Articles