How to map a subdomain to a subfolder

How to map a subdomain to a subfolder

This one proved a little trickier than I expected. I’m using wordpress and h2o webserver. YMMV.
I am not using WPMU

The goal: map -> /var/www/html/subdomains/test
NB: Your hmtl root dir may vary. I use ubuntu 16.04

1. DNS – Create a CNAME record on your DNS host which is an alias of your domain name
1.1 Point browser to It should re-direct to your current wordpress install

2. Create a virtual host on your web server listening for your subdomain i.e. “”. I need to edit /etc/h2o/h2o.conf. If you’re using nginx or Apache look away now!

3. Load webserver with new config: sudo service h2o restart
4. Create a dummy index.html file in your subfolder
4.1 chown and chmod as required.

5. Point browser to Success?
5.1 for bonus points create and test an info.php file

Only install wordpress after confirming webserver is well, serving

6.Install wordpress into your subfolder and configure
6.1 – Grab the latest zip/tar from
6.2 – gzip -d and tar –strip-components=1 -xvf latest.tar can prove useful.
6.3 – configure mysql database and user privileges for new WP instance

6.4 – nano wp-config.php and ensure following are present:

as well as db connectivity params

6.5 Need keys & salts? Go here

6.6 Point browser to and complete wordpress installation.

All things being equal should now load your new WP instance!

Don’t forget to delete index.html and/or info.php file after successful wp install.

Leave a Reply

Be the First to Comment!

Notify of