Skip Navigation

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

Problem:
If you're experiencing server errors on your site that make it very slow and often go away when you reload the page, we have identified a potential solution.
Solution:
First, you might be facing an issue that requires adding specific code to your theme's functions file to correct rewrite rules:

1. Using FTP, navigate to `/wp-content/themes/your-theme`.
2. Open the `functions.php` file for editing.
3. Add the following code and then save the changes:

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

For more details, please refer to the documentation: https://wpml.org/faq/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website/.

Additionally, to identify the exact cause of the errors, enable debugging in your site.

To enable it, open your wp-config.php file and look for define('WP_DEBUG', false);. Change it to:

define('WP_DEBUG', true);

To enable the error logging to a file on the server, you need to add yet one more similar line:

define( 'WP_DEBUG_LOG', true );

The errors will be saved to a debug.log file inside the /wp-content/directory.

https://wpml.org/documentation/support/debugging-wpml/

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. 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 23 replies, has 0 voices.

Last updated by Andrey 1 week ago.

Assisted by: Andrey.

Author Posts
April 7, 2025 at 6:14 pm #16905618

stevenK-22

Background of the issue:
I am experiencing server errors on my site hidden link. I am trying to work on the site, but the errors make it very slow. I attempted to follow a link for troubleshooting: https://wpml.org/forums/topic/internal-server-error-23/ but couldn't understand the instructions.

Symptoms:
I get server errors about 50% of the time, which often go away when I reload the page.

Questions:
How the heck can i fix this 😀

April 7, 2025 at 8:58 pm #16906396

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for reaching out to WPML support.

You may be experiencing an issue mentioned in another thread. Here are the steps to resolve it:

1. Using FTP, navigate to `/wp-content/themes/your-theme`.
2. Open the `functions.php` file for editing.
3. Add the following code and then save the changes:

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

For more details, please refer to the documentation: https://wpml.org/faq/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website/.

April 8, 2025 at 5:12 am #16906655

stevenK-22

Hi Andrey,

Thanks for the reply. I added that to my functions.php (at the end of the file, hope it doesn't matter where I added it?), but it didn't seem to change. I'm still getting a lot of server errors, which makes working on the page pretty tricky...

April 8, 2025 at 1:25 pm #16909643

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for your feedback.

Yes, it is expected to be added at the end. If you temporarily deactivate the WPML plugin, do you no longer get errors?

Before making any changes, please ensure that you back up your database first.

April 10, 2025 at 4:19 am #16916387

stevenK-22

Hi Andrey,

Sorry for the late reply, I didn't have much time yesterday to work on the site.
OK, so i deactivated WPML... and no i have no server errors!

But i felt bad deactivating it 😀

April 10, 2025 at 6:16 am #16916588

stevenK-22

update: deactivating it and working on it for an hour, i've had zero server errors, and the wp-admin site is super fast. :/ But clearly i need to re-activate it, as we need both BG and EN language options/etc.

April 10, 2025 at 12:51 pm #16918712

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for your feedback. Yes, you can activate it again.

We need to check what those are. The first step is to enable debugging. You can add a few lines to the site’s wp-config.php file. With the error log enabled, you will see the actual problem.

To enable it, open your wp-config.php file and look for define('WP_DEBUG', false);. Change it to:

define('WP_DEBUG', true);

To enable the error logging to a file on the server, you need to add yet one more similar line:

define( 'WP_DEBUG_LOG', true );

The errors will be saved to a debug.log file inside the /wp-content/directory.

https://wpml.org/documentation/support/debugging-wpml/

Let me know what you see in the debug.log file after the debug mode has been enabled at the moment of the error.

April 13, 2025 at 4:55 am #16925979

stevenK-22

Hi Andrey,
Again, sorry for the delay! I entered the following into the wp-config.php file for you!
I had the pluging turned off the last day/s so i could fix a bunch of the issues on the pages that I couldn't fix before due to the server errors (basically there are so many errors that it's not really possible to work, they come up every page reload when the plugin is turned on). I'll turn the wpml plugin back on now!

Thanks for helping,
Steve

define( 'WP_DEBUG', true );

/* Add any custom values between this line and the "stop editing" line. */

define( 'WP_DEBUG_LOG', true );
/* Put this in for WPML. */

April 13, 2025 at 5:09 am #16925982

stevenK-22

FYI, before i even turned WPML back on (the plugin), I'm getting the following errors already at the top of my wp-admin page:

Deprecated: Automatic conversion of false to array is deprecated in /home/hipstorb/public_html/wp-content/plugins/wpml-sticky-links/classes/class-wpml-sticky-links.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/hipstorb/public_html/wp-content/plugins/wpml-sticky-links/classes/class-wpml-sticky-links.php:19) in /home/hipstorb/public_html/wp-admin/includes/misc.php on line 1438

Warning: Cannot modify header information - headers already sent by (output started at /home/hipstorb/public_html/wp-content/plugins/wpml-sticky-links/classes/class-wpml-sticky-links.php:19) in /home/hipstorb/public_html/wp-includes/functions.php on line 7137

Warning: Cannot modify header information - headers already sent by (output started at /home/hipstorb/public_html/wp-content/plugins/wpml-sticky-links/classes/class-wpml-sticky-links.php:19) in /home/hipstorb/public_html/wp-admin/admin-header.php on line 9

April 13, 2025 at 5:23 am #16925984

stevenK-22

OK! WPML is back on... the error log/debut is on!

April 13, 2025 at 3:48 pm #16926604

stevenK-22

Ooo, and now after doing the debug/log thing, when i go to the webpage,... this nasty error shows up at the top! looks... bad 😀
please help!
cheers,
Steve

Errors-Hipstor-Screenshot 2025-04-13 184759.jpg
April 13, 2025 at 3:52 pm #16926622

stevenK-22

I mean looks bad if new customers are checking our webpage (which is admittedly, sadly not a crazy amount daily, but.. not a great impression). Buuut, still looks bad 😀

traffic-7-days.jpg
April 14, 2025 at 7:15 am #16927386

stevenK-22

Okay, now the page doens't load at all, and that's very bad. I may have to turn off whatever logging you had me add to the wp-config file, as the page isn't loading/broken 🙁
Is there something i can send?

April 14, 2025 at 7:17 am #16927472

stevenK-22

Here is the error messages i get trying to hit the home page:

broken-homepage.jpg
April 14, 2025 at 7:38 am #16927538

stevenK-22

FYI, I changed the de-bugging to false/false again, as the page now wasn't loading at ALL (not just showing the errors at the top), but i'll try to check your reply quickly, and can turn it back on asap when you are around if needed!