Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

WordPress Adds a Warning to .htaccess Edits

Long overdue information

         

not2easy

8:40 pm on Dec 2, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I was editing an .htaccess file on a WordPress site today after getting everything updated and spotted something new. I found out years ago that you just don't mess with the .htaccess snippet - the code that ensures that WP URLs are created according to settings. It is a default piece of code that doesn't vary from one typical WP install to another. To my surprise it now has a warning to try to keep folks from editing that section of their .htaccess file:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Good move imo. ;)

TorontoBoy

8:49 pm on Dec 2, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



I'm not surprised. The WP htaccess is a critical part of the system and if messed with can down the site. I've not heard of an error message though. This piece of code is also available in the WP codex.

I put all my WP installs in subdirs, with my htaccess in the root, which provides some inheritance. I therefore do not modify the WP htaccess.

tangor

9:57 am on Dec 4, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Commonsense! Wonder why it took so long?

lucy24

6:21 pm on Dec 4, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If I remember rightly, there was a time when WP simply took over your entire htaccess: install an upgrade, and they overwrote the whole file. When this changed, they forgot to include a clear warning: “Yes, the rest of the htaccess is yours, but you still have to leave this part to us” even when it includes things like <IfModule> that would normally never be present in any specific individual site’s configuration files and you’re just itching to delete the lines

not2easy

7:55 pm on Dec 4, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



just itching to delete the lines
Indeed. Years ago (many) I did just that - edited the WP snippet to clean up ( I thought) unnecessary lines of code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
and found out I shouldn't have done that, had to put it back. It may make perfect sense, but WP works in its own environment, one that apparently can't function without its peculiarities.