• Does .htaccess in public_html have final say?
    I thought the .htaccess file in public_html overwrites other .htaccess in other directories. So whatever is in that .htaccess file, it will be applied everywhere. The one in cgi-bin directories only works for the directories and paths inside the cgi-bin directory. Same as the htaccess in wp-admin and others.
    Is this true?

    And what happens when both .htaccess have the same rules, except the htaccess in wp-admin says “allow” and the public_html says “deny”? Will the rules in public_html always overrule?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I thought the .htaccess file in public_html overwrites other .htaccess in other directories.

    In my own limited experience, a second .htaccess *can* over-rule the first *unless* the first (at least initially) sends a domain on past it. For example, I have my Primary Domain assigned to public_html where it is then re-directed to a sub-folder, and the .htaccess there in public_html tells my domain what to do when it arrives at its sub-folder. But if my domain cannot find at the sub-folder what it was sent there to do, then the .htaccess in my sub-folder takes over to handle the error (404).

    I thought the .htaccess file in public_html overwrites other .htaccess in other directories. So whatever is in that .htaccess file, it will be applied everywhere.

    I just now happened to see this affirming at least that part:

    .htaccess files follow a hierarchy. Whatever directives are in the top-level .htaccess file flow down and apply to all directories below it.
    https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-40

    However, I believe it is still possible for a later ‘RewriteEngine Off‘ to stop certain actions.

    Thread Starter olifantje

    (@olifantje)

    Thanks, so I can assume that if de top-level htaccess says “no” the ones below that have a htaccess that says “yes”, it wil stil be a “no”.

    …so I can assume that if the top-level htaccess says “no” the ones below that have a htaccess that says “yes”, it wil stil be a “no”.

    Edit: Oops, no, I think the latter will re-write the rule.

    Here is a comprehensive tutorial and guide:

    https://perishablepress.com/stupid-htaccess-tricks/

    Thread Starter olifantje

    (@olifantje)

    thanjs for the ‘stupid’ tricks :p will take a look!

    About your edit, are you as confused as I am? I think I’m going to try it out to be sure, because I still don’t understand the exact hierarchy.

    About your edit, are you as confused as I am? I think I’m going to try it out to be sure, because I still don’t understand the exact hierarchy.

    I only have one eye that can read, and my edit came about after I had realized I had mis-read what you had posted!

    I am just beginning to learn about .htaccess beyond copy-and-paste from other sources, but, and as an example here, I believe ‘RewriteEngine On‘ turns it on and it remains that way until Apache might be given a ‘RewriteEngine Off‘ order from wherever. More to the point here, I believe a ‘RewriteRule ...‘ applies wherever and both in the immediate and well as later either unless or until a new-and-related ‘RewriteRule ...‘ is encountered by Apache.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘.htaccess’ is closed to new replies.