0

We have a php project / php web-application where users can create profiles which more or less looks like a website on a sub-domain URLs like robert.blogger.com. Now this user also has a domain of his own example robert.com. Now we want every request for robert.com to redirect to robert.blogger.com without changing the URL.

The URL should show robert.com/home.html, robert.com/aboutus.html etc. but actually code should be run from robert.blogger.com/index.html, robert.com/aboutus.html etc.

Please note that the project is hosted on a dedicated server with dedicated IPs & we also have access to the Control Panel of the user's domain.

We have tried htaccess but that only redirects, we want masking / mapping to work.

Is this possible? If so, how can this be done? Would appreciate much !!!

2 Answers2

0

The solution would depend on what kind of server software you're running, but in Apache you'd do this by mapping the default vhost for the IP to the application (and then letting people point their domain to that host), and in your application use HTTP_HOST in $_SERVER to look up the valid domain (which you're probably already doing to map the subdomain to user accounts). This would be the exact same thing, as long as you keep all links relative in your HTML (and don't think "i mapped it to this user, so the domain should be user.example.com").

To give a more specific answer you'd have to be more concrete in your question.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
0

It should be possible to use ProxyPass in htaccess, if you have permissions to use it. Try something like this.

ServerName robert.com
RewriteRule ^/(.*)$ http://robert.blogger.com/$1 [L,P]

Or you can map it in your application, depends if that server is yours and you can do anything you want to setup.

martin.malek
  • 2,166
  • 2
  • 19
  • 31