Skip Navigation

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

Problem:
The client is experiencing intermittent 'Internal Server Error' messages when trying to access translated pages on a website with WPML and WCFM installed. The hosting company suggested that the issue might be related to a misconfiguration in the htaccess file.
Solution:
We recommended the following steps to resolve the issue:
1. Take a backup of the site for safety reasons.
2. Add the following code in the functions.php file of the 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 the 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 the issue persists, 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 reply, has 0 voices.

Last updated by rayaA 1 day, 6 hours ago.

Assisted by: Noman.

Author Posts
December 18, 2024 at 2:45 pm #16526309

rayaA

Background of the issue:
I am trying to reach a translated page after a fresh installation of WPML on a site that has WCFM on it. The issue can be seen at: hidden link

Symptoms:
Sometimes I see the page, but sometimes a white page comes up with the error: Internal Server Error. The server encountered an internal error or misconfiguration and was unable to complete your request. The hosting company mentioned misconfiguration issues in the htaccess file and suggested creating a default htaccess file. I attached two photos- one with the error, the second when the pages loads successfully. The error is inconsistent, sometimes comes up and sometimes not.

Questions:
What could be causing the Internal Server Error when accessing a translated page?
How can I resolve the htaccess file misconfiguration issue?

December 19, 2024 at 9:21 am #16528912

Noman
Supporter

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

December 22, 2024 at 9:31 am #16537344

rayaA

Thank you. I found out which was the offending plugin (Frontend Admin), I disabled it and the problem went away only after re-saving the permalinks from the Settings >> Permalinks page by pressing the Save Changes button. I decided not to use this plugin so the problem is resolved.