1

In my webhosting package, the primary domain points to the root of my file system and any extra domains that I add point to subfolders.

The problem is, the .htaccess for the primary is influencing not just the primary website's files, but also secondary websites in the subfolders. This is causing confusion and is not very desirable.

So, is there a way to tell the secondary websites to ignore all .htaccess statements bleeding down from the root? Or do I have to explicitly override each statement in each .htaccess each time I add/change the one in the root?

(It is shared hosting so I have limited control, but any answers gratefully accepted as I may be able to use this to hastle the provider).

1
  • FYI - your question is a good question, but is not regarding professional systems administration (you are a system user, not administrator). I've flagged it for migration to webmasters.SE, where it is on topic, and the folks there have had much more experience with shared hosting providers. No need to re-post over there.
    – EEAA
    Commented May 11, 2013 at 18:39

2 Answers 2

1

This isn't really a property of .htaccess files, but of Apache configuration directives in general - many directives being applied in a <Directory> or <Location> block will apply to child directories, and .htaccess files are essentially another way to configure <Directory> blocks.

If you had control over where the subdomains were in the directory structure, or the configuration of the virtual hosts for the subdomains, that would be a much better solution - having the subdomains as subdirectories of a main domain is a pretty bad design.

The behavior of directives is very dependant on which directives you're using - can you provide details about what directives you're having problems with?

2
  • Thanks Shane. I was trying to set up / understand expires and cache-control. So I would like to reset everything to with this (etags, expiries, cache control headers etc) so I can then start from scratch. There is a broader worry though: the primary site is Drupal which has a v. complicated .htaccess and I wonder how it will mess things up when I install websites in subdirectories using other CMSs. Commented May 11, 2013 at 18:56
  • @spiderplant0 Yeah.. that's a bit tricky, especially dealing with Drupal's hideous htaccess file. I'd say try to get the host to point the main site at a subdirectory. Commented May 11, 2013 at 19:01
0

Well so lets assume you set up your main directory in /home/myusername/public_html like in usual CPanel or something. So you have your main .htaccess affecting from its definition all the child subdirectories underneath public_html.

What you could do though in Cpanel or whatever you use, set up your main domain something like this: /home/myusername/public_html/mymaindomain which would put your main .htaccess in the sublfoder of /public_html. So now every other domains/subdirectories you create under /public_hmtl are not affected by main domain .htaccess.

Hope this helps.

1
  • Thanks Danila, however my hosting company (godaddy) doesnt seem to allow you to change where the primary domain point to - it seems to be fixed to point to the root). Commented May 11, 2013 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.