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 ?
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 ?
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:
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:
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:
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.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.