Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my shared hosting, I have just created a new subdomain static.example.com but it has also create a new folder www.example.com/static/ .

How can I avoid to create these new folders every time I create a new subdomain ?

share|improve this question

migrated from stackoverflow.com Jul 17 '12 at 4:39

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

I guess the reason why this folder is created is simple. The hosting company just adds a entry into your DNS zone file, something like:

static        A        W.X.Y.Z

where W.X.Y.Z is the IP of your existing site 'example.com'. Then they'd creates a virtual host in apache config - static.example.com and sets its DocumentRoot to <server_path>/public_html/static.

I am sure your problem is not with the folder itself (how else will you organize all the files for static sub-domain if not in a subfolder) but with the fact the files are also accessible via the URL www.example.com/static

One solution is that you can ask your hosting company to put the static folder outside your current document root so that it is not addressable as a subfolder of current DocumentRoot.

What I mean to say is that your current directory structure could look like:

\
- public_html
   - static

where public_html is your DocumentRoot for example.com (couldbe called httpdocs or some other name based on your hosting env)

You need to ask them to move static folder only level up to something like:

\
- public_html
- static

static is now a sibling of old DocumentRoot and not a child of it. It will be no longer addressable via www.example.com/static now. /static is a new DocumenRoot for your new subdomain.

share|improve this answer
add comment

On a shared hosting site the hosts software normally does this. I think this is an unintended behavior and you should contact your host provider. It is not normal that a subdomain can be accessed via appending a path to the main domain.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.