-
-
Notifications
You must be signed in to change notification settings - Fork 37
Placement of Directives #16
Comments
It's literally the first line of code. add_action('generate_rewrite_rules', __NAMESPACE__ . '\\ApacheServerConfig::init', -9999, 0); There's not much else that I know of that I can do besides set it to the lowest priority like that so that it hopefully gets processed first. I have noticed that sometimes it's not first, and I'm not sure why, but I also didn't care. WordPress only has rewrite rules, so this really isn't that big of a deal, imo. If you want to give it a shot and send a PR, feel free. |
Will test at some point during the the next fortnight. Thanks again. |
@QWp6t you might be able to use add_action('generate_rewrite_rules', __NAMESPACE__ . '\\ApacheServerConfig::init', PHP_INT_MIN, 0); |
That's only for PHP 7.0+. But it's not absolutely necessary to be the very first, so I'm not concerned about that. |
It is necessary to be first for some of the directives to be effectual. .htaccess is read from top to bottom and directives are observed in read-order. Once the WordPress rewrites are reached, WordPress takes over for virtual files and directories that are managed by WP and thus applies WP PHP based rewrites. For example, where we want to deny access to a file or directory, if WP kicks in before the .htaccess directive that blocks access to a document that is read by Apache then that directive might not be observed in time to prevent the document being served. Another example, the directives that gzip output are best placed at the top of .htaccess so they take effect immediately and not after the files have already been served. Placement does matter. Maybe prepend the directives to htaccess and include DirectoryIndex at the top? |
Shouldn't the boilerplate .htaccess directives go before the WordPress ones?
.htaccess being processed top-to-bottom, when the WordPress directives are placed earlier than the H5BP directives it means the H5BP directives are processed too late i.e. after WordPress has already processed requests.
The text was updated successfully, but these errors were encountered: