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: http://joesmith.yourdomain.com 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 ns1.domain.com. admin.domain.com. (
    4 ; serial
    8H ; refresh
    2H ; retry
    2W ; expire
    1D ; default_ttl
    )
    IN A 192.168.1.233
    IN NS ns1.jrox.com.
    IN NS ns2.jrox.com.
    www IN A 192.168.1.233
    * IN A 192.168.1.233

  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:

    <VirtualHost 255.255.255.0>
    DocumentRoot /home/username/public_html
    ServerName
    www.domain.com
    ServerAlias domain.com
    ServerAlias *.domain.com
    </VirtualHost>

  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="http://www.yourdomain.com/affiliates/js/sub/1/<?=$args[1]?>"></script>
  6. Change yourdomain.com/affiliates in the Javascript code above to reflect your affiliate program URL.
  7. Now all of your affiliate links will look like:

    http://username.yourdomain.com

  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.