• Hi.

    We love your plugin, but the way it works causes problems.
    Having a .htaccess file in the wp-content/uploads folder will block all rewrite rules in the websites main .htaccess as Apache will only use the .htaccess file in the deepest matching subfolder.

    In your htaccess file you state (loosely translated) “you should not change this, but use WordPress filters”. I would suggest you do the same; use the WordPress filters to alter the main .htaccess file which is written on a Permalink save.

    Thank you, with kind regards,
    Remon.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author rosell.dk

    (@roselldk)

    Hi,

    Sorry for the late reply.

    .htaccess files doesn’t work exactly as you state. The rewrite rules in the main .htaccess aren’t blocked. However, the rules in the subfolder does take precedence, meaning that if a rewrite rule matches, it will be executed before the rules in the main .htaccess gets to look at it.

    The rewrite rules only react on image requests (and only if you activated them). In which case does that cause trouble?

    There are a couple of reasons for putting the rules in a subdir. One of them is actually to ensure that the rules are prioritized over other rules! It is also slightly better for performance that the server only needs to process the rules when dealing with uploads and not on all requests.

    The message about using filters is auto generated by WordPress (the “insert_with_markers” function). The purpose of the message seems to be to keep people from manually changing the directives in the block. I wasn’t aware of these instructions. They didn’t use to be there. But with WebP Express they make no sense, as WebP Express doesn’t provide any filters for tweaking the rules. Instead, the rules are tweaked through the plugin settings.

    Thread Starter Internetbureau Clearsite

    (@clearsite)

    .htaccess files doesn’t work exactly as you state.

    My apologies for wording incorrectly.

    Yes, you are correct in saying “only when rules apply to the same request”
    The way it causes trouble is, for instance, when using a set of rules to automatically watermark images if the image-request is from an external service, or to filter image requests through code to strip harmful code from Exif tags.

    When the WebP rules are in the root htaccess where the watermark and/or exif filter rules are, then ALL those rules are processed in succession, instead of just the rules in the uploads folder.

    I know this, because I have a script running that moves all the webp-express rules to the main htaccess and all functions now work correctly.

    Thank you anyway for your reply 🙂
    I now know I will have to keep maintaining my code to “fix” the rewrite rules and will create a plugin to do so in our private repository.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘.htaccess files in wrong locations’ is closed to new replies.