Developing ecommerce, conversion-oriented and transactional web apps since 1998.
Full stack PHP developer. Front end developer.

Portfolio

Here are a few sites that I've developed.

Averett University
Northwest Missouri State University
Talladega College
Morgan State University
The University of Texas Permian Basin
Warren Wilson College
Catawba College
Manhattanville College

How I setup this page using wildcard subdomains on Apache

Notice that this page and each of the portfolio pages uses a subdomain (portfolio.tombartling.com), rather than a subdirectory (tombartling.com/portfolio). Why?

Easy to maintain: wildcard subdomains do not require additional changes to DNS and web server configuration

For each addition to the portfolio, I only need to create a directory and upload the files. There's no need to add records to the DNS or add VirtualHost directives to the Apache config.

Easy to upload: subdomains allow links to work properly

Each site references root-level assets, meaning that the style sheets, images and javascript files are linked to from the web root. This would not work if these portfolio sites were in subdirectories. Therefore, I made them subdomains to avoid having to change all of the links and references to external files. How did I configure this and why did I choose that method?

Steps to setup wildcard subdomains on Apache

I added two A records to the DNS:

  • portfolio.tombartling.com.   IN A 159.89.189.66
  • *.portfolio.tombartling.com.   IN A 159.89.189.66

Notice the second one starts with the * wildcard, which means that any subdomain off the portfolio.tombartling.com subdomain points to 159.89.189.66.

I added two virtual hosts to Apache, one for each of the two subdomains listed above.

VirtualHost for portfolio.tombartling.com

<VirtualHost *:80>
ServerName portfolio.tombartling.com
ServerAdmin tom@tombartling.com
DocumentRoot /sites/tombartling.com-prod/portfolio-files
</VirtualHost>

VirtualHost for *.portfolio.tombartling.com

<VirtualHost *:80>
ServerAlias *.portfolio.tombartling.com
ServerAdmin tom@tombartling.com
VirtualDocumentRoot /sites/tombartling.com-prod/portfolio-files/%1
</VirtualHost>

The first one uses ServerName and DocumentRoot, while the wildcard one uses ServerAlias and VirtualDocumentRoot. The %1 tells Apache to use whatever the wildcard subdomain is as the directory name (e.g., http://caramel.portfolio.tombartling.com points to /sites/tombartling.com-prod/portfolio-files/caramel). In order for VirtualDocumentRoot to work, I enabled the module vhost_alias.load.