Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)
-
22-04-2021 - |
Domanda
I’ve got a pretty weird behavior on my site that I’d like to resolve.
From time to time (no recognized pattern), my site shows a 500 error, on the front pages or on some admin pages. When this 500 error shows on the front pages, the admin pages are still usable.
I’ve found by chance a way to fix this: by going to the Permalinks settings page (/wp-admin/options-permalink.php
) without submitting anything! The simple fact of going to this page resolves the error.
I’ve noticed that options-permalink.php
is calling this url:
https://public-api.wordpress.com/rest/v1.1/me?http_envelope=1&fields=ID%2Cusername
with this response:
{"code":200,"headers":[{"name":"Content-Type","value":"application\/json"}],"body":{"ID":[my_id],"username":"[my_username]"}}
But I don’t know how there could be a relationship between the 2...
FYI, I’ve recently migrated from one hosting provider to another so it may be a configuration problem on the server because there wasn't any error back then.
Thanks for your time! Any help appreciated :-)
Update after @vancoder suggestion: I made a diff between the 2 versions of .htaccess file before and after the problem occurs:
Working site:
RewriteBase /
RewriteRule . /index.php [L]
Non working site:
RewriteBase /fr/
RewriteRule . /fr/index.php [L]
My site is multilingual based, but with only the french language set for now. Do you know which plugin could be the culprit (WPML? Really Simple SSL?) ? Have any of you encountered the same problem before?
FYI, here's the list of all my activated plugins:
- Contact Form 7
- Contact Form 7 to Hubspot
- Cookie Notice & Compliance for GDPR / CCPA
- Elementor
- Facebook for WooCommerce
- HubSpot All-In-One Marketing - Forms, Popups, Live Chat
- HubSpot for WooCommerce
- ImageMagick Engine
- Jetpack
- Porto Theme
- Really Simple SSL
- Site Kit by Google
- WooCommerce
- WooCommerce Google Analytics Integration
- WooCommerce Multilingual
- WooCommerce Shipping & Tax
- WooCommerce Stripe Gateway
- WordPress Zero Spam
- WPML Media
- WPML Multilingual CMS
- WPML String Translation
- WPML Translation Management
- WP Super Cache
- WPvivid Backup Plugin
- Yoast SEO
- Yoast SEO Multilingual
Thanks again for your help!
Soluzione
Looks like it might be your WPML.
See here: https://wpml.org/forums/topic/wpml-add-rewritebase-en-in-htaccess/
For posterity, the summary of this page is as follows:
Problem: Some wrong settings caused an issue with "Use directory for default language". A 500 error was showing. Solution: The client reports here that pressing the 'Reset Settings' button in WPML -> Languages probably solved the problem.