Affiliate Software Documentation

Setting Up Dynamic Subdomain Links

What are Dynamic Subdomains?

Dynamic subdomains allow you to set-up affiliate links that use the username as the subdomain for your affiliate link.

For example: where joesmith is the affiliate's username.

Dynamic Subdomain Affiliate Link Requirements:

  • Access to your DNS records
  • You will need to be able to edit your DNS or name server records to enable dynamic subdomains.
  • Access to your Apache Web Server Configuration File
  • You will need to be able to edit your Apache's httpd.conf file to enable dynamic subdomains.

Steps to Enable Dynamic Subdomain Affiliate Links:

  1. Your home page must be in php, such as index.php

  2. Edit Your Name Server / DNS Records - You will need to enter a wildcard subdomain entry for your DNS records. If you use BIND as your name server, it would go as the last line on your DNS record as follows:

    @ IN SOA (
    4 ; serial
    8H ; refresh
    2H ; retry
    2W ; expire
    1D ; default_ttl
    IN A
    IN NS
    IN NS
    www IN A
    * IN A

  3. Edit Your Apache httpd.conf file - You will need to edit your httpd.conf file and add a ServerAlias entry near the bottom of your Virtual Host record as follows:

    DocumentRoot /home/username/public_html
    ServerAlias *

  4. Enable the dynamic subdomain links in Settings > Global Configuration > Marketing > Affiliate Marketing > Affiliate Link Type and set it to dynamic. You can also specify restricted subdomains in the Restricted Subdomains field so that users will not create affiliate usernames with them.

  5. Copy and paste the following JavaScript code into your home landing page (should be index.php):

    <?php preg_match("/^([^\.]+)\./",$_SERVER['HTTP_HOST'],$args); ?>
    <script src="<?=$args[1]?>"></script>
  6. Change in the Javascript code above to reflect your affiliate program URL.
  7. Now all of your affiliate links will look like:

  8. When a user clicks on an affiliate link like the one above, they will be redirected to your home page, and the Javascript code you added on the landing page will set the tracking cookie.