Skip Navigation

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

Problem:
The client is experiencing an 'Internal Server Error' that occurs randomly when navigating their site. The error seems to be resolved when the 'WPML Multilingual CMS' plugin is deactivated.

Solution:
We recommend the following steps to address the issue:
1. Ensure to back up the site for safety reasons.
2. Add the following code to the

functions.php

file of the 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 types of caches including site/server cache, plugin cache, CDN cache, and clear the browser cache.

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

If the solution provided here is not relevant due to being outdated or not applicable to your case, 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 the issue persists, please do not hesitate to open a new support ticket with us.

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 3 voices.

Last updated by Noman 1 year, 2 months ago.

Assisted by: Noman.

Author Posts
March 9, 2024 at 12:01 pm #15391361

enriqueV-8

Error message "internal server error" keeps popping up during navigation. It appears randomly, maybe 1 every 10 times that I enter a new page within my site.

After clearing caché, deactivating and reactivating plugins, etc. the problem is fixed only when I deactivate "WPML Multilingual CMS" plugin (4.6.9 installed). If deactivated, then everything is ok. When I reactivate, the problem happens again.

.htaccess seems to be ok:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

March 9, 2024 at 12:59 pm #15391461

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

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

Hi there.

Before this ticket gets assigned to my colleagues, I will try to help.

1. Usually, the 500 errors (Internal Server Errors - blank pages) are related to the server configuration or server limitations being reached.

You can check our documentation to see if you meet all the WPML minimum requirements here: https://wpml.org/home/minimum-requirements/

2. Also, please take a look here:
https://wpml.org/faq/500-error

3. You can also activate WordPress debug to find out more about what is actually happening when you receive that 500 error:
https://wpml.org/documentation/support/debugging-wpml/

4. This issue might also be caused by incompatibility or not 100% compatibility between WPML and (at least) one of the active plugins or the active theme.

Can you please try to see if this issue happens even when only the WPML plugins are active and you are using a default WordPress theme?

Please try the following steps so that we can test for a compatibility-related issue:

- create a full website backup

- disable all plugins except WPML and its add-ons

- check if the issue is happening again

- if it's not, reactivate your plugins one by one, checking every time if the issue shows up again so that you can understand which plugin is causing that issue

If the issue happens even with the non-WPML plugins disabled:
- leave all the non-WPML plugins deactivated

- switch to a default theme like TwentySeventeen

- try to recreate the issue now

If you have the chance, it would be best to do this in a staging (testing) environment.

I hope that you will find this information helpful.

Please let us know how things go.

Mihai Apetrei

March 10, 2024 at 11:03 am #15392403

enriqueV-8

HI Mihai,

Thanks for your email.

I have gone through all the recommendations in your email and I am still having the same problem: “Internal server error” message appears as I navigate through my website.

- I have changed the “Salient” Theme to” Twenty twenty-four” and the problem persists aprox. 1 to 2 out of 10 times I open a new page while navigating.

- I have disabled all plugins, and the problem only appears when I activate “WPML Multilingual CMS”

- All plugins and theme updated

- I have checked everything mentioned in your email and all seems to be ok.
o WordPress 6.4.3
o PHP 8.3.2
o MariaDB 10.5
o WPML multilingual CMS 4.6.9
o Memory Limit 256M
o Memory limit: 256M
o REST Activated: yes
o SimpleXML extension loaded
o Multibyte String extension loaded
o All plug-ins are up to date

See screenshot attached (in Spanish)

- For some reason I couldn't’ create the debug.log after adding

define('WP_DEBUG', true);
define( 'WP_DEBUG_DISPLAY', false );

to wp-config.php.

the debug.log file would not show up in /wp-content/ directory.

- However, when the “internal server error” happens, on apache.error.log, I read the following:

[Sat Mar 09 18:05:00.946448 2024] [core:error] [pid 174729:tid 139668368615168] [client 77.224.184.59:0] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

- After doing a back-up of .htaccess and renaming the original file, the problem persists.
The new .htaccess says:

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I don’t know what else can I try. It appears that the problem is on the “ WPML Multilingual CMS” plugin, as the “internal server error” only comes up when this plugin is on.

Many thanks in advance for your help.

Thank you.

Enrique

ScreenHunter 2590.jpg
March 10, 2024 at 12:16 pm #15392524

Noman
WPML Supporter since 06/2016

Languages: English (English )

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

Hi,

Thank you for contacting WPML Support. Based on the details you provided, it appears that the issue may be related to specific plugins or themes on your site. To address this, could you please follow the below steps and see if this resolves your issue:

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

2. Please 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. Please re-save the permalinks from the Settings >> Permalinks page by pressing the Save Changes button and see if this resolves your issue.

4. Please 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 is a doc for more details:
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

March 10, 2024 at 1:01 pm #15392557

enriqueV-8

EXCELLENT!! THANK YOU!!

Apparently, your recommendation worked great. I can now navigate with no errors.

Thank you so much for your quick reply, especially on a Sunday 😄

Best regards,

Enrique