I built a LAMP web application that let's users create their own profile page where they can upload their resume and portfolio. The url for a person's profile will be something like
http://jobbank.com/user/johndoe
John Doe registers the domain name http://johndoefreelancer.com and he wants it to point to http://jobbank.com/user/johndoe. Anyone who visits johndoefreelancer.com should not be aware that it's driven by http://jobbank.com/user/johndoe. This means that the browser url should persistently show addresses such as:
http://johndoefreelancer.com/aboutme (really points to jobbank.com/user/johndoe/aboutme) http://johndoefreelancer.com/portfolio (really points to jobbank.com/user/johndoe/portfolio)
Additionally, clicking on any links [a href=""] should keep you at johndoefreelancer.com instead of sending you to jobbank.com.
My question is, what is the best way to achieve this?
I'm considering: 1) Give instructions to users on how to domain forward with masking
2) Instruct users to fillout the field $homeUrl in their User Profile information, which is saved to the database
3) In my PHP code, if $homeUrl exists, replace all [a href="$_SERVER['HTTP_HOST']"] with [a href="$homeUrl"]
Is this the right approach? Is there a better way?
An alternative approach would be to tell your users to point their domains to your IP and set them up as name-based virtual hosts. The benefits are:
This would be easier to setup if you did not have to use /user/johndoe
prefix for your URLs (which you don't really need to because you can do a domain lookup in your code to determine user id), but is possible with the prefix as well - it's just that mod_rewrite setup would have to be more involved in that case (you'll need to do it per domain).