katura
katura

Reputation: 2237

Is it possible to URL mask a domain name with a different one using mod_rewrite?

Here is the scenario -

I have a website where customer's websites run under mine.

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

An example of the index.html with a redirect to my site:

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

Is it possible to add a rewrite directive using mod_rewrite that will take the customer's domain, such as www.customer1.com and not only redirect it to my site with the variable named "number", but also mask the rest of the pages accessed thereafter?

So that it would appear to anyone browsing the site that they were "still" under customer1.com and not see mainsite.com instead?


Edit

The customer's website/domain is hosted on the same vps as my own website. My site is built on JSP pages.


Upvotes: 4

Views: 3310

Answers (2)

Piskvor left the building
Piskvor left the building

Reputation: 92762

Not using mod_rewrite, but there's mod_proxy, which does what you want (you need to enable and load the module, it is not enabled in default config):

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

Note that 1) this makes all the "masked" traffic appear to come from your host (instead of the user's host), and also 2) any load on the masked host will go through yours.

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

Upvotes: 2

Cristian
Cristian

Reputation: 327

Why you dont use the <jsp:forward> instead of mod_rewrite ?

Upvotes: 1

Related Questions