WPML – .htaccess is rewritten with language folder

Symptoms

In certain cases, the .htacess may get overwritten with the language folder. However, this issue is not caused by WPML.

The problem actually comes from certain third-party plugins calling flush_rewrite_rules(true) function too often. This causes WordPress to overwrite .htaccess. However, in some cases, this happens so often, sometimes even on every page request, that it’s called while browsing the front-end in another language.

When this happens, WPML goes ahead and adds the language folder to home_url as usual. This, however, results with an incorrect RewriteBase in .htaccess and ends up breaking the front-end.

Workaround

The proper fix is for the third-party plugin to flush the rewrite rules only once. This would result in better performance of plugins in question because flushing rewrite rules is a server-expensive operation and extra care should be taken.

However, we can also avoid the language folder from being added within WPML. As a temporary workaround you can add the following lines to the functions.php of your theme:

Leave a Reply

Your email address will not be published. Required fields are marked *


Math Captcha
48 − 41 =