[Resolved] Bug: website paths broken due to htaccess edit by wpml
This thread is resolved. Here is a description of the problem and solution.
Problem: You are experiencing issues where your .htaccess file was unexpectedly modified during a plugin update, changing the RewriteBase and RewriteRule and causing all pages to become unavailable. You suspect that the WPML plugin is responsible for these changes. Solution: We want to clarify that WPML does not modify your .htaccess file. The issue might be caused by third-party code, possibly from an SEO plugin or other custom code, that uses the
flush_rewrite_rules(true)
function too frequently. To identify the source, we recommend searching your codebase for occurrences of
flush_rewrite_rules
using your IDE. Meanwhile, maintaining any current workaround should help prevent further issues while you test if this resolves the problem.
Please note that this solution might be outdated or not applicable to your specific case. If the issue persists, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If necessary, do not hesitate to open a new support ticket with us for further assistance at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Hi,
can you tell me please how and why it is possible that your plugin during the latest update changed my .htaccess file ?
In the website my primary language is dutch (nl), my secundary language is english (en), and for some reason your plugin decided to change the RewriteBase and RewriteRule. Causing all pages to become unavailable. I lost an hour investigating and solving it. It is clearly a bug on your side in your code to have assumed the primary language in the site is english and then automatically change the htaccess file.
Sometimes, third-party plugins call the flush_rewrite_rules(true) function too often. This leads to changes in the rewrite rules in your .htaccess file, which can cause issues on your WordPress site.
You can use the workaround posted there and also keep it active long-term if needed.
I still don't quite understand the mechanism, but I will apply the snippet.
Also, it still does not explain why the WPML plugin would apply the secundary language instead of the first, does it? I would expect the behaviour of adding '/en/' to the htaccess file should at least be corrected by using the primary language (which is 'nl' but set as root in my case) instead of the secundary, wouldn't you agree?
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: Europe/Vienna (GMT+02:00)
Hi Maxim,
I think there may be a misunderstanding.
WPML does not modify your .htaccess file. The issue is likely caused by third-party code that is calling the flush_rewrite_rules(true) function too frequently. This could be coming from your SEO plugin or any other custom or third-party code that uses this function.
To identify the source, you can search your codebase locally using your IDE and look for occurrences of flush_rewrite_rules.
In the meantime, the suggested workaround should prevent the issue, so it’s safe to keep it active and test whether it resolves the problem on your end.
My assumption that WPML was causing it was mostly based on the fact that no other plugin knows about the extension /en/. But I read about it again, and now understand it is triggered by a visitor, visiting a english page, and a rewrite function then fires the parse_url function on that english page with extension /en/. That makes sense.