This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're using the MasterStudy LMS plugin recommended by WPML and notice that your website becomes inaccessible due to htaccess modifications, this might be relevant to you. The issue arises when third-party plugins frequently call the
flush_rewrite_rules(true)
function, leading to unwanted changes in the htaccess file.
Solution:
We recommend following these steps to address the 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'); 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 your permalinks from the Settings >> Permalinks page by pressing the Save Changes button.
4. Clear all types of caches including site/server, plugin, CDN, and browser caches.
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 resolve your issue or 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 problem persists, please open a new support ticket at https://wpml.org/forums/forum/english-support/.
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.