How to enable user custom domains in PHP

You won't merge their domain to your server.

In fact, when they will register their domains, they will make it point to your server.

On your server configuration, you'll have to dynamically create rules that implicitly redirect the page to the one they created on your server.

So, users will see http://purchaseddomain.com/on-uri but you serve the page http://domain.com/custom-name/one-uri

I.E: it's like if you added on an .htaccess - even if you don't use apache, it's just to explain what the "system" must be:

RewriteCond %{HTTP_HOST} purchaseddomain\.com$ [NC]
RewriteRule (.*) /custom-name/$1