Skip Navigation

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

Problem:
The client experienced an error 500 on all pages of their website except the homepage, which was temporarily fixed by adding code to the .htaccess file. The hosting provider identified the issue as related to WPML and advised adding code to the functions.php file.
Solution:
We suggested that the problem might be due to the .htaccess file being overwritten with the language folder, which is not directly caused by WPML but by third-party plugins calling the

flush_rewrite_rules(true)

function too often. We recommended following the steps provided in the WPML errata page:

If the provided solution does not resolve the issue or seems irrelevant due to being outdated or not applicable to the client's case, we encourage the client to open a new support ticket. We also highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that the latest versions of themes and plugins are installed. For further assistance, please contact us in the 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.

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by Prosenjit Barman 11 months, 3 weeks ago.

Assisted by: Prosenjit Barman.

Author Posts
February 14, 2024 at 9:34 am #15300760

hansD-23

I had an error 500 on all pages of my website maisonbotanique.be except the homepage.
I contact my hosting provider support (siteground) for this and they told me that the issue is in WPML.

For now we fixed it with a code in htaccess file but they told me to contact WPML support to have a code I can't add in my functions.php file of my theme. Thats why I contact you. My base language is dutch.

February 14, 2024 at 9:39 am #15300888

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

Thank you for contacting WPML support. While you are waiting for one of my colleagues to take this ticket and work on it, let me provide you with the first debugging steps and try to help with the issue quickly.

I think you are having the next issue: 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.

Please try the next solution:

- https://wpml.org/errata/htaccess-is-rewritten-with-language-folder/

Let us know how it goes.

Regards,
Drazen

February 14, 2024 at 10:13 am #15301138

hansD-23

I need to add this code to my functions.php

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;
}

February 15, 2024 at 9:46 am #15305741

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,

I hope you're doing well. I've taken over this ticket and would be happy to assist you further in this matter.

Thank you for implementing the code. Could you please let me know if adding the code has resolved the issue with accessing the other pages? If you're still having the issue, please go to "Settings > Permalinks" and save the permalink structure. In this way, the rewrite rules will be flushed and hopefully, the issue will be resolved after that.

Let me know the update. I will be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit