Using htaccess to create a subdomain on apache
I've been thinking of starting a blog to keep my thoughts and ideas together in one place. To do this I wanted to use a simple subdomain to nixadmins.net like blog.nixadmins.net. To do this in a simple way without touching too much of the configuration I did it using the Apache's .htaccess file.
The htaccess file can be used to many things, in this short short story I'll only go in to creating a working subdomain. But you can find a lot more in the htaccess tutorial.
If you have a .htaccess file you can modify it, if not just create a new one in any editor.
Put the following lines in it, and of course change the values to suite your need.
RewriteEngine on
# Rewrite for Wordpress blog
RewriteCond %{HTTP_HOST} blog.nixadmins.net
RewriteCond %{REQUEST_URI} !blog/
RewriteRule ^(.*)$ blog/$1 [L]
</IfModule>
After that, create a DNS cname record, of blog.nixadmins.net that points to the same server, for me www.nixadmins.net. And you are done.