How to enable user custom domains in PHP How to enable user custom domains in PHP codeigniter codeigniter

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


This is what is working for me:

server {    server_name *.mydomain.com    root        /var/www/$host;    ...}

Then you need to make directories like: /var/www/user1.mydomain.com/, /var/www/user2.mydomain.com/, ...

I couldn't figure out how to leave the '.mydomain.com' out of the directory name. If anyone has any idea, pls let me know :)