Support

Home Forums Community Forum htaccess file corruption issues causing the 404 Errors

htaccess file corruption issues causing the 404 Errors

Posted: August 15, 2022 at 8:30 am


TBWA-Web

August 15, 2022 at 8:30 am

file keeps getting overwritten and causes the frequent 404 errors. While working last night in the background of our site, I received this error on two separate occasions:
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
What can be done to ensure the problem is fixed?


Tony

  • Support Staff

August 16, 2022 at 9:15 am

Hi there,

Is this on an EE event endpoint or something else?

EE itself does not alter your .htaccess file, it does call to flush permalinks but does so using WordPress itself using flush_rewrite_rules() which can rewrite .htaccess to the default.

Are you adding your own write rules to .htaccess?


TBWA-Web

August 16, 2022 at 12:50 pm

I have used these two configs of the htaccess but both have been overwritten by something to make the site fail:
1-
# BEGIN HTTPS Forced Redirect
# The directives (lines) between “BEGIN HTTPS Forced Redirect” and
# “END HTTPS Forced Redirect” are dynamically generated, and should
# only be modified via the filters. Any changes to the directives between
# these markers will be overwritten.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# END HTTPS Forced Redirect

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

and 2 –
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Every time we update EE or do a batch process of events the htaccess gets overwritten.


Tony

  • Support Staff

August 16, 2022 at 2:43 pm

Do you not have # BEGIN WordPress and # END WordPress comments or are they just not included above? Those are used by WordPress to know where its own rules are.


TBWA-Web

August 16, 2022 at 6:40 pm

When the overwrite knocks the site offline, the #BEGIN WordPress and #END WordPress appears on the bad htaccess file. I’ve been removing it and the site goes back online. We have to get the site stable so registration for the event can begin (now postponed 5 days). Can you tell me what is causing this cycle of 404 Errors?


TBWA-Web

August 16, 2022 at 7:08 pm

Thanks for your help with this. It’s really stressful for this small non-profit. I deactivated the ReallySimple SSL plugin, since BlueHost has the Let’s Encrypt SSL feature that forces the https on the domain. For the record, both of these were turned on and the site didn’t have 404 Errors before the last WP update to 6.0 and EE’s recent update.


Tony

  • Support Staff

August 16, 2022 at 7:11 pm

When the overwrite knocks the site offline, the #BEGIN WordPress and #END WordPress appears on the bad htaccess file.

WordPress has its own set of rewrite rules that must be present, to find those rules within the htaccess file it uses the #BEGIN WordPress and #END WordPress

If you are removing those comments WordPress can’t find the default rewrite rules and will simply overwrite the file.

I’ve been removing it and the site goes back online.

What exactly are you removing?

This is what you should have by default most of the time:

https://wordpress.org/support/article/htaccess/

Anything outside of those is custom and being added by something else.

Can you tell me what is causing this cycle of 404 Errors?

No, because the issue above isn’t clear currently.


TBWA-Web

August 16, 2022 at 9:05 pm

Thank you! That worked and the site didn’t go down. BlueHost had provided us a default htaccess file but it didn’t have the #BEGIN/#END WordPress language.


Tony

  • Support Staff

August 18, 2022 at 12:59 pm

Awesome, I’m glad it worked 🙂

The support post ‘htaccess file corruption issues causing the 404 Errors’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso