Skip to content Skip to sidebar

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

Problem:
If you're experiencing frequent 404 errors on the translated versions of your pages (EN and IT) on your website, which uses DE as the default language, this might be due to an issue with third-party plugins affecting the rewrite rules.
Solution:
We recommend trying the following steps to potentially resolve this issue:
1. Ensure you 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 />  <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 />  <br />    $rules = str_replace("RewriteBase $home_root", "RewriteBase $wpml_root", $rules);<br />    $rules = str_replace("RewriteRule . $home_root", "RewriteRule . $wpml_root", $rules);<br />  <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 cache, plugin cache, CDN cache, and your browser cache.
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 becomes 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. Should you need further assistance, 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 3 replies, has 0 voices.

Last updated by Noman 1 month, 1 week ago.

Assisted by: Noman.

Author Posts
December 9, 2025 at 4:54 pm #17648865

martinS-159

Our website brancaia.com has DE as its default language and is translated to EN and IT.
We are experiencing frequent 404 errors on the EN and IT languange versions. These errors can occur on any existing(!) page, and they come and go. The error 404 message does not come from WordPress, but from the webserver.
To reproduce the problem, pick any EN or IT page (e.g. hidden link) and reload it a few times. Sooner or later you will run into an error 404.
Since this problem occurs on the translated pages only, we suspect a problem with WPML. Can you please support us?
This video illustrates the problem: hidden link

December 10, 2025 at 9:02 am #17650672

Noman
WPML Supporter since 06/2016

Languages: English (English )

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

Hi,

Thank you for contacting WPML Support. Thanks for the video, I can see the issue on your site. 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

December 15, 2025 at 8:59 am #17663119

martinS-159

Hi,

thank you for your reply. I have implemented the code, and for the moment I don't see these error messages anymore. Please let me test it for some days before closing this ticket.

December 15, 2025 at 11:03 am #17663783

Noman
WPML Supporter since 06/2016

Languages: English (English )

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

That sounds good. Please take your time to test it over the next few days, and let us know if the issue appears again.

Thank you