• Resolved mlajos

    (@mlajos)


    Hello, everyone!

    I’m wrinting in hope of this note reaching the developers of wordpress.

    On the servers, where we host our wordpress and non wordpress sites, we run PHP-FPM, which needs an extra line of code, if we use htaccess:
    RewriteCond %{REQUEST_URI} !^/fastcgiphp/*

    I read several forums where they complain about the htaccess being rewritten by wordpress and they keep getting the reply, that the code between # BEGIN WordPress and # END WordPress should be off limits for developers.

    James Huff(MacManX) wrote this reply in this post:
    https://wordpress.org/support/topic/htaccess-keeps-getting-overwritten?replies=5

    Make sure than any additions made to the .htaccess file are place outside of the “# BEGIN WordPress” and “# END WordPress” tags. WordPress will manage whatever is inside those tags (and that includes deleting foreign entities).

    Tell me again, please, where should I write my code, if not before the RewriteRule line? I am waiting for an example code.

    This is an issue I’m facing every time I need to change something on a wordpress site, no matter, which version. My code needs to go before the last RewriteRule in the file, otherwise the PHP will not run and the site will throw an 500 internal server error and there is no workaround.

    WordPress should at least provide an editor to edit the template of the htaccess code they are copying to the file.

    To the developers: I beg you to take this issue in consideration and start working on a solution, because this has caused me far more trouble, than it should have. Don’t think you can write some ultimate htaccess code, that is good for every server and every setup, so please stop the arbitrary rewriting of htaccess files.

    Thank you, for listening, I hope, that in future versions of wordpress, this issue will finally be solved.

    Greetings from Hungary,
    Louis

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    If you need to add that line anywhere before the last rewrite line, and outside of the WordPress section, why not add it to the very beginning of the file, like so?

    RewriteCond %{REQUEST_URI} !^/fastcgiphp/*
    # BEGIN WordPress
    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    It appears that this rule is intended to have it not do the rewrite to the index.php file if “/fastcgiphp/” is in the requested URI. In which case, you should probably make a separate ruleset to force it to stop processing instead. Reverse the logic, basically. Instead of ignoring the index.php rewrite for those cases, force it to not process further rules for those cases.

    So, maybe something like this above the WordPress rules?

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/fastcgiphp/*
    RewriteRule . - [L]

    This says that if /fastcgiphp/ is in the URI, then Rewrite anything (dot matches all patterns) to the special dash rule, which means to take no action. The [L] is the Last modifier, which forces it to stop processing.

    So, if /fastcgiphp/ is in the URL, then no action is taken, and the WordPress ruleset following it gets ignored.

    Does that work for you?

    Edit: Removed the ! from the rule. You want to match that condition, not the other way around.

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    Great catch, Otto! I probably shouldn’t answer threads as I’m just waking up. 🙂

    Thread Starter mlajos

    (@mlajos)

    Thank you guys for the answers, gonna try out the solutions and gonna write back with the results. The current solution is – as of the time I opened this topic – that I set the htaccess non writable at all through console.

    Thread Starter mlajos

    (@mlajos)

    Well what do you know, it solved it :O

    Otto, you’ve solved a whole year’s issue, which I was too frustrated, annoyed and furious to solve.

    Still, I feel, that an editor would be nice in wordpress for advanced webdevelopers, who want to edit the htaccess. Most people have a htaccess snippet, that they got used to, and would not want to think of a workaround just to satisfy wordpress’ needs.

    Thank you very much, both of you guys, for your time to come up with this solution. I really thought, that there can be only one mod_rewrite block in the htaccess – don’t ask, why I thought, I never tried to do the other way, I guess.

    The question is resolved. The solution is: you can use multiple mod_rewrite blocks in htaccess.

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    I’m glad that worked out for you! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Yet another rant about htaccess being rewritten by wordpress’ is closed to new replies.