I'd describe myself as a fairly advanced PHP programmer and I'm about to start work on a new project.
Basically, the user will purchase an account and create their own profile. If they want, they can point their personal domain to their profile on our website.
开发者_StackOverflow中文版Problem is... how do I get their domain to point to their profile?
Set your project as the default virtualhost in apache (a virtual host that will be used for domains that don't have an own one). Don't know how you call it on apache.
Then check $_SERVER['HTTP_HOST']
in PHP to get the domain name. You can then redirect to the profile page or show it directly under that domain name.
People have to point their domain to your IP address (or point a subdomain to your IP using CNAME
)
On your side, you can create a virtual host in apache (or whatever) to map from usercustomdomain.com to their profile. A drirective like this may be enough for you:
<VirtualHost *:80>
DocumentRoot c:/htdocs
ServerName usercustomdomain.com
Redirect permanent / /profile.php?user=329
</VirtualHost>
On their side, using their DNS provider, they need to create a cname record for usercustomdomain.com to point to your webserver's address. This is pretty easy with go daddy or whatever but you'll probably want to give the user some documentation on your site on how to do so.
精彩评论