#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189

    .htaccess for subfolder to ignore .htaccess in root folder


    I'm trying to make the .htaccess file in a subfolder (actually an add-on domain) NOT also process rules in the root folder.

    I've spent the last hour or more searching Google...

    Any assistance?
    Thomas Tremain
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    As far as I know you can't. However, you can override most directives with a new value.

    If by rules you mean rewrite rules though, it might not be possible to override them. Try putting RewriteEngine off into your subfolder .htaccess file. If that disables the rules, then you can override them. If it doesn't, then you can't.

    If you can't, then you'll need to modify the rules in the parent directory's .htaccess file so that they don't apply to URLs referencing the subfolder.

    For an add-on domain it does seem kind of odd that the parent directory's .htaccess file is being processed; if you're accessing the subfolder using the add-on domain directly I wouldn't think that the parent folder would be under the add-on domain's document root, and as far as I know, .htaccess files that are above the document root would not be processed.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189
    For an add-on domain it does seem kind of odd that the parent directory's .htaccess file is being processed; if you're accessing the subfolder using the add-on domain directly I wouldn't think that the parent folder would be under the add-on domain's document root, and as far as I know, .htaccess files that are above the document root would not be processed.
    That is what I show from tests on my own servers, as well. My client has yet to give me FTP access in to take a look at this account. I posted this based upon his notes, and the more I look, the more I think he's mistaken.

    Apache on *MY* servers, map the add-on domain DIRECTLY to it's own folder, so the public_html/.htaccess should never be accessed.

    This thread may be moot... Then again, you have probably confirmed what I thought to be true.
    Thomas Tremain
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189
    My client was correct. When he went to his add-on domain, it was reading the .htaccess file from the root domain.

    I was then able to recreate this on my own servers...

    The fix:

    In the root of the add-on domain, I created a .htaccess file, and placed in it only:

    RewriteEngine On
    RewriteBase /

    If I left the .htaccess file in this folder blank, it again read the .htaccess file for the primary domain.

    All servers tested were running Centos, and cPanel.
    Thomas Tremain

IMN logo majestic logo threadwatch logo seochat tools logo