• Resolved 3Lancer

    (@3lancer)


    Hi,

    I’m getting an Internal Server Error 500 on one of my servers.

    It occurs at 4:30am each morning, WordPress or a plugin is rewriting the ‘.htaccess’ file. The code it is adding is valid, but a duplicate of what is already in it below.

    Basically the ‘# BEGIN WordPress’ section is being added again in the middle of ‘# BEGIN W3TC Browser’ content above. This is the same code as below without any changes… it’s just like it’s verified the code and cut short on reading/writing to the file? Cleaning it up is easy, but then it attempts to do it again the following days.

    File permission for ‘.htaccess’ is set at 660. If that matters?

    Error log: .htaccess:375: <FilesMatch> was not closed.

    It’s referring to (which looks closed to me):

    <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
        <IfModule mod_headers.c>
            Header set Pragma "public"
            Header append Cache-Control "public"
             Header set X-Powered-By "W3 Total Cache/0.9.4"
        </IfModule>
    </FilesMatch>

    However am I able to remove those or recreate them? Is the W3TC content also meant to be at the top before the WordPress rewrites?

    Also wondering if server has a limit on the max length written in PHP? Appears to of just started happening when the ‘.htaccess’ got longer?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter 3Lancer

    (@3lancer)

    Fixed – was due to another plugin being limited…

    For others:

    Check limit of ‘max_input_vars’ on the server php.ini

    Increase PHP Memory from WordPress default 40MB (or 64MB) to recommended 128MB if required for support of WooCommerce, other certain plugins and/or high visitor traffic – under your wp-config.php:
    define('WP_MEMORY_LIMIT', '128M');

    Disable other plugins / cronjobs if possible to narrow down the issue.

    WooCommerce and Amazon plugin was causing issues and this was just a side effect of it, WordPress itself overwriting the ‘.htaccess’ file in the wrong location.

    Hi,

    I am also getting same Internal Server Error 500. It occurs at 10:00 at each morning. Some process is updating htaccess file and add </FilesMatch> tag.

    Thu Oct 09 10:11:39 2014] <FilesMatch> was not closed., referer:

    Could please let me know how did you fixed this issue ?, even WP_MEMORY_LIMIT is 256M.

    Thanks

    Thread Starter 3Lancer

    (@3lancer)

    You need to recreate that ‘.htaccess’ file or disable it from automatically being update by various different plugins.

    It’s normally just a spacing, or missing of the end comment, etc, which can throw it off.

    For example:
    # BEGIN WordPress
    (all this content is what wordpress generates)
    # END WordPress

    Then when other plugins come along such as security and this caching, they will may place more above.

    # BEGIN W3TC Browser Cache
    (caching here)
    # END W3TC Browser Cache

    etc… they all have to match perfectly.

    Make a backup of a working ‘.htaccess’.

    You might have to disable other plugins from accessing your ‘.htacccess’ – set them all to manual for now.

    Depending on your visitors. Delete the one on the server, create an empty ‘.htaccess’ replacement, then under the WordPress Admin quickly update your permalinks (simply resave it under your options). WordPress will then full back in the ‘.htaccess’.

    Once WordPress has done it’s chuck, then do the plugins that have also added content into the ‘.htaccess’ one by one – testing each time. Or manually copy and paste it into the correct locations.

    In my case though, the root cause was due to running of large cronjobs at that point of time.

    For WordPress cronjobs – I moved them to real server cronjobs, this tends to work a lot better and provide less overlapping/conflict for large jobs that take time. This is however more complex and if WordPress Plugins also have their own cronjobs, they need to be setup separately.

    If you wanted to do that too under ‘wp-config.php’:
    define(‘DISABLE_WP_CRON’, true);

    Then on your server recreate the cronjob, for example:
    */15 * * * * cd /wordpress/location/ && /usr/bin/php /wordpress/location/wp-cron.php >/dev/null 2>&1

    This is basically saying each 15 minutes go to the WordPress directory and run the WordPress CronJob ‘wp-cron.php’ on a Linux server. If your unsure about Cron Jobs, I wouldn’t suggest trying it, they need to be setup correctly or your WordPress won’t do schedule posts, htaccess updates, etc.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘was not closed?’ is closed to new replies.