Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with rewrite rules like

RewriteRule ^bs/wp-login.php /wp-login.php [QSA,L]

and similar for other language directories, it might be due to third-party plugins calling the

flush_rewrite_rules(true)

function excessively.
Solution:
We recommend trying the following steps:
1. Back up your site for safety.
2. Insert the following code into the functions.php file of your theme:

add_filter('mod_rewrite_rules', 'fix_rewritebase');<br />function fix_rewritebase($rules){<br />    $home_root = parse_url(home_url());<br />    if ( isset( $home_root['path'] ) ) {<br />        $home_root = trailingslashit($home_root['path']);<br />    } else {<br />        $home_root = '/';<br />    }<br />    $wpml_root = parse_url(get_option('home'));<br />    if ( isset( $wpml_root['path'] ) ) {<br />        $wpml_root = trailingslashit($wpml_root['path']);<br />    } else {<br />        $wpml_root = '/';<br />    }<br />    $rules = str_replace("RewriteBase $home_root", "RewriteBase $wpml_root", $rules);<br />    $rules = str_replace("RewriteRule . $home_root", "RewriteRule . $wpml_root", $rules);<br />    return $rules;<br />}

3. Re-save your permalinks from the Settings >> Permalinks page by pressing the Save Changes button.
4. Clear all types of caches: site/server, plugin, CDN, and browser.
For more details, visit https://wpml.org/faq/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website/

If this solution does not apply to your case, or if it seems outdated, 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 issues persist, please open a new support ticket 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.

This topic contains 1 replies, has 1 voice.

Last updated by Noman 3 days, 23 hours ago.

Assisted by: Noman.

Author Posts
February 1, 2026 at 4:13 am #17780736

eamonnT

are these added by wpml
RewriteRule ^bs/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^nl/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^en/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^fr/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^de/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^it/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^ja/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^pl/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^pt-br/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^es/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^th/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^en-US/wp-login.php /wp-login.php [QSA,L]

February 2, 2026 at 3:20 pm #17784515

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. This type of issue usually arises due to some third party plugins when they call flush_rewrite_rules(true) function too often and it can only be fixed directly by the plugin author.

As a quick workaround, could you please try to follow the below steps and see if this resolves your issue:

1. Please take a backup of your site first for safety reasons.

2. Add the below code in the functions.php file of your theme:

add_filter('mod_rewrite_rules', 'fix_rewritebase');
function fix_rewritebase($rules){
    $home_root = parse_url(home_url());
    if ( isset( $home_root['path'] ) ) {
        $home_root = trailingslashit($home_root['path']);
    } else {
        $home_root = '/';
    }
  
    $wpml_root = parse_url(get_option('home'));
    if ( isset( $wpml_root['path'] ) ) {
        $wpml_root = trailingslashit($wpml_root['path']);
    } else {
        $wpml_root = '/';
    }
  
    $rules = str_replace("RewriteBase $home_root", "RewriteBase $wpml_root", $rules);
    $rules = str_replace("RewriteRule . $home_root", "RewriteRule . $wpml_root", $rules);
  
    return $rules;
}

3. Re-save the permalinks from the Settings >> Permalinks page by pressing the Save Changes button.

4. Delete all sorts of caches on your site/server cache if any / plugin cache / CDN cache, clear the browser cache, and then see if it resolves the issue afterward.

Here you can see more details about it:
https://wpml.org/faq/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website/

Please let me know the results,
Thank you for your cooperation