How to have each folder within a root folder act as a subdomain?

Posted March 24, 2013 2.1k views
Hello there, I am new to DigitalOcean and new to server management. What I am trying to achieve is that, I want each of my folder in the root folder, act as a subdomain. For e.g: and should be the same directory, and should be same. At my old host, I just use to create folders within the root directory and then they were accessible as subdomains. I am trying to achieve the same effect. Someone was helping me with this on the chat, but then we were waiting for my dns to get updated. So far he ased me to add * in CNAME and point it to and put a .htaccess file in the root folder, which looks like the following; RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.mywebsite\.co\.uk RewriteRule ^(.*)$$1 [L,NC,QSA] At the moment any subdomain I try, it goes to the main root directory. for example:,, all goes to the index.html file in /var/www. folder1 and folder2 exists in the root but blahblah doesn't exists. Can someone please help me. Regards Salman

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer
What does your does the rest of you Apache config look like?