Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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).

share|improve this question

migrated from serverfault.com May 12 '13 at 1:40

This question came from our site for professional system and network administrators.

    
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 May 11 '13 at 18:39
add comment

2 Answers 2

up vote 1 down vote accepted

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?

share|improve this answer
    
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. –  spiderplant0 May 11 '13 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. –  Shane Madden May 11 '13 at 19:01
add comment

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.

share|improve this answer
    
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). –  spiderplant0 May 11 '13 at 18:52
add comment

Your Answer

 
discard

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

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