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: Exception
This topic contains 5 replies, has 3 voices.
Last updated by Andrey 1 year, 3 months ago.
Assisted by: Andrey.
Author | Posts |
---|---|
September 26, 2023 at 8:10 am #14464053 | |
arnoP-3 |
Hello, The problem described here happened to me a few days ago: https://wpml.org/errata/htaccess-is-rewritten-with-language-folder/ This entire section in htaccess: #The directives (lines) between "BEGIN WordPress" and "END WordPress" are ... all of a sudden was replaced by a German version, which is the secondary language of the site. Even the above comment lines were German. All pages other than the homepage failed to load. After some research, I found the problem and manually put the English version back. I have no idea what exactly caused it. If I understand your article correctly, some other plugin than WPML probably messed with the htaccess file? If that happens, WPML gets confused but that can be prevented with the “temporary” workaround? Is that still the workaround or is this built into WPML by now? In that case, it didn't seem to work for me. Kind regards, |
September 26, 2023 at 8:46 am #14464553 | |
George Botsev Supporter
Languages: English (English ) Timezone: Europe/Sofia (GMT+02:00) |
Hello! In that snippet, the only thing from WPML is these lines: RewriteRule ^en/wp-login.php /wp-login.php [QSA,L] RewriteRule ^de/wp-login.php /wp-login.php [QSA,L] They are related to the setting to translate the login pages, which you can turn off in WPML > Settings |
September 26, 2023 at 8:50 am #14464611 | |
arnoP-3 |
Hi George, The snipped I pasted was the original correct one. It contains "RewriteBase /". It was "spontaneously" replaced by this: #Die Anweisungen (Zeilen) zwischen „BEGIN WordPress“ und „END WordPress“ sind |
September 26, 2023 at 9:15 am #14465137 | |
George Botsev Supporter
Languages: English (English ) Timezone: Europe/Sofia (GMT+02:00) |
Okay, so this is indeed the same issue. The workaround is not implemented in WPML to my knowledge and you should have to apply it. I would like to suggest testing with a minimal set of plugins. I know this could be tricky... Another option would be to try and obtain the `home_url()` by a different means - if in example something is modifying the value somehow, you can try to modify the errata workaround to something like this: add_filter('mod_rewrite_rules', 'fix_rewritebase'); function fix_rewritebase($rules){ global $wpdb; $option_name = 'home'; $query = $wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = %s LIMIT 1", $option_name); $option_value = $wpdb->get_var($query); $home_root = parse_url($option_value); 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; } |
September 26, 2023 at 10:04 am #14465661 | |
arnoP-3 |
When I manually put the English version back in htaccess, the issue was actually fixed. My main worry now is that I don't know why it happened and would like to prevent it. I guess the only thing I can do is put the "temporary" workaround in place. I thought it was part of WPML but I will have to do it myself, right? |
September 26, 2023 at 2:25 pm #14467753 | |
Andrey Supporter Languages: English (English ) Russian (Русский ) Timezone: Europe/Kyiv (GMT+02:00) |
Thank you for your feedback. The issue might happen due to a combination of third-party plugins flush_rewrite_rules(true) function too often, as stated in the article. Yes, you might need to use the workaround to prevent this from happening. |
September 29, 2023 at 6:08 am #14485509 | |
arnoP-3 |
Ok, I will do so and hope it will not happen again. |