Report this

What is the reason for this report?

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

Posted on March 24, 2013

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: mywebsite.co.uk/folder1 and folder1.mywebsite.co.uk should be the same directory, mywebsite.co.uk/folder2 and folder2.mywebsite.co.uk 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 mywebsite.co.uk and put a .htaccess file in the root folder, which looks like the following;

RewriteEngine on RewriteCond %{HTTP_HOST} ^(.).mywebsite.co.uk RewriteRule ^(.)$ http://mywebsite.co.uk/%1/$1 [L,NC,QSA]

At the moment any subdomain I try, it goes to the main root directory. for example: folder1.mywesbite.co.uk, folder2.mywebsite.co.uk, blahblah.mywebsite.co.uk 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



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

What does your does the rest of you Apache config look like?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.