• Resolved Nela

    (@nelchee)


    I actually solved this problem by myself, but I have to let you folks know that this is causing issues, and should be fixed.

    I didn’t even know this was happening for months until someone recently reported a broken link on my website, because my dozens of 301 redirects weren’t working at all.

    I had a .htaccess file full of custom rules before I installed W3TC. Apparently, the plugin inserted its own rules and deleted all of mine. Completely. There was not one custom rule left in my file. (I can’t remember which version was this, but it was a while ago.)

    The plugin did not warn me it would alter my .htaccess file, or suggested I back it up. I had no way of knowing it has done that. I had no reason to check the file.

    Thankfully I had an old local backup that I was able to copy my rules from today, and only when I copied them before BEGIN W3TC Browser Cache did my redirects start working again. So my suggestions for improvement:

    1. Warn users that the plugin will alter their .htaccess file and offer to back up the contents.
    2. When adding W3TC rules, add them after everything that’s already in there, not before. Because any 301 redirects have to come before W3TC rules in order to work. Once W3TC messes with the URL structure, they will no longer match with the URL redirect rules, and the result is a 404 error.

    If there’s a better place to send this suggestion let me know, but I hope you can forward this to your dev team.

    • This topic was modified 12 months ago by Nela.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @nelchee

    Thank you for reaching out and thank you for sharing the recommendations.
    Yes, you are correct, some custom rules work only when set before other rules.
    W3TC rules should not be added after the WordPress default rules. W3 Total Cache adds the rules according to the configuration since the rewrite is done via .htaccess or nginx.conf.
    W3 Total Cache does not remove the existing rules, however, you should make sure to add the rules with the comments like #begin and #end to avoid any possible conflict

    Thank you again for sharing this as this will be great for other users that may experience similar issues, and we’ll make sure to add some documentation about this to avoid problems in the future.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin breaks .htaccess 301 redirects: my suggestion for how to resolve’ is closed to new replies.