PHP, Creator Economy

Custom Domain Support in Creator Economy Platforms

Photo by Viarami on Pixabay

Most creator platforms support two forms of custom domains:

  • 1. Subdomains - such as johndoe.platformX.com
  • 2. Custom domain - such as platformX.johndoe.com

Describing the creator domain as part of the URL of the site, such as www.platformX.com/johndoe, is much less common.

If you are about to construct such a platform, you may wonder how complicated it is to build custom domain support.

It turns out it is straightforward.

It boils down to two things:

  1. 1. The user doing setup in their domain registrar or website hosting company
  2. 2. Routing in your platform

Domain Setup by User

You should instruct users to add appropriate DNS records in their domain registrar or hosting company. There are many examples of instructions in existing platforms that you can borrow.

The Transistor podcasting platform instructions that I recently used are excellent.

Routing in Platform

While I do not know which backend programming framework or language you use, the following in Laravel PHP is pretty generic and can be adapted to:

  • 1. Any PHP framework
  • 2. Express.js or any Node.js backend framework
  • 3. Ruby on Rails
  • 4. Java Spring Boot

Domains


Route::group(['domain' => '{subdomain}.{domain}.{tld}'], function(){

    Route::any('/', function($sub, $domain, $tld){
        return 'custom domain: ' .  
            $sub . '. ' . 
            $domain .  '. ' . 
            $tld;
    });

});

Subdomain


Route::domain('{account}.example.com')->group(function () {
    Route::get('user/{id}', function ($account, $id) {
        //
    });
});

Yoram Kornatzky

Yoram Kornatzky