• There seems to be a long-standing bug that causes W3 Total Cache to write its .htaccess rules starting on the end of the last line in the file. I ran several test installations across two different hosts (to rule out the host) to chase this down to find a trigger.

    So here is how this works. Single site installations of WordPress will write its own .htaccess rewrite rules surrounded by two comments, “# BEGIN WordPress” and “# END WordPress”. When W3TC writes rules, it apparently looks for the BEGIN comment. If it finds it, the rules prepend the WordPress ones (in other words, they get placed before the # BEGIN comment). If it doesn’t find it, it appends them to the end of the document. Since there usually isn’t a line break at the end of the file, this will typically make W3TC run into the last written line, with the W3TC starting comment being placed at the end of whatever line is there.

    If that line happens to be a comment, no big deal. If it isn’t, you get a 500 error when Apache freaks out because it doesn’t know what to do.

    This is especially troublesome for multisite because the rewrite rules are not surrounded by the BEGIN and END comments. Once W3TC writes to the file, the 500 error happens until the file is manually edited.

    Since this has been happening for a while, I’m wondering when this will be corrected. It seems that if W3TC doesn’t see the # BEGIN comment, it either thinks the file is empty or it just doesn’t know where to put the code.

    https://www.ads-software.com/plugins/w3-total-cache/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ashok

    (@bappidgreat)

    Hello Asheboro

    This is usually happens when you use one click installer to install wordpress. It doesn’t create standard htaccess (leave begin and end wordpress comment).

    So, this is kinda true:

    It seems that if W3TC doesn’t see the # BEGIN comment, it either thinks the file is empty or it just doesn’t know where to put the code.

    I hope, the author will take care of this. But still, using one click installer is not a good idea, there are lots of drawbacks of it.

    Have a good day!

    Cheers
    Ash

    Thread Starter Asheboro

    (@asheboro)

    This issue occurs with installers and manual installation. This is not unique to installers like Softaculous, as it also does this with manual installations, which I also tested.

    There is no difference between the .htaccess Softaculous created for me and the one WordPress created through a manual installation. The same breakage happens on manual and installer setups.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘500 Error from appending to last line in htaccess’ is closed to new replies.