Skip Navigation

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

Problem:
The client reported a recurring 404 error due to the automatic modification of the .htaccess file by the WPML plugin, which incorrectly rewrites rules based on the language of the site, causing navigation issues.
Solution:
We identified this as a known issue not directly caused by WPML but related to its interaction with .htaccess configurations. We recommend following the workaround detailed in our FAQ to prevent .htaccess from being overwritten when the language changes. You can find the step-by-step guide here: 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, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we encourage you to open a new support ticket for further assistance.

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 12 replies, has 2 voices.

Last updated by Andreas W. 9 months, 3 weeks ago.

Assisted by: Andreas W..

Author Posts
August 10, 2024 at 4:47 pm #16058692

nativeW

Now it's better, thank you and all the images are there again. However, there's is two issues persisting. For example, when you change the language and go to "our rooms" in the menu, now it's ok but if you refresh da page it goes to a 404 error. The other one, that it's not new, is about the checkout cart. You can make a complete an order in Portuguese, but in any other languages when you should go from the Amelia reservation to the woo commerce checkout it gives another 404 error page. I noticed the there is two pages for each language of the checkout page. (you can make all the reservations you need to test because you have the option to pay on location - "pagamento na entrega"

August 10, 2024 at 5:04 pm #16058702

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

I can see the issue and further, it also looks as if the issue from our first ticket regarding the missing design is back.

I will be taking a copy of the site for further testing and then get back to you.

August 10, 2024 at 9:48 pm #16058890

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I have been running tests on a virtual server with a copy of your site and I can not confirm the 404 issues here.

The issue might be somehow related to your server setup and I would like to ask you to set up a staging site on which we can run further tests.

The private reply form is enabled again. If you can not provide access to such a staging site, please let me know.

Best regards
Andreas

August 11, 2024 at 10:24 am #16059208

nativeW

Yes, the design is ok. I made a backup restore and follow some of your previous advices (memory limit and elementor content translation) and now seems the design is working well. Related to the 404 error is still there and it is difficult to understand because it works just in portuguese, so it seems the server shouldn't be the problem. I did what you recommend, erase all the duplicate pages not used and even change the slug to the original but continues to give the 404 error when it should goes to the checkout page. I don't know how to make a staging website. I will upload some prints to explain the 404 error in English for example.

I'm not an expert but I feel like is something related to cache or something related to Amelia and woo commerce communication by wpml translations of endpoints maybe?

Because if you try no go directly by url to the checkout page in any language Bokkusu.pt/checkout it opens the page correctly but when you finish the purchase it gives another error agains instead of come back to the finish page of Amelia like it does in the original language, Portuguese.

Captura de ecrã 2024-08-11, às 11.13.25.png
Captura de ecrã 2024-08-11, às 11.13.34.png
Captura de ecrã 2024-08-11, às 11.13.43.png
Captura de ecrã 2024-08-11, às 11.10.46.png
August 13, 2024 at 2:49 pm #16066958

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

It is not recommended to run tests on your live site, as I need to access the file on the server to debug the issue and disable plugins temporarily, maybe even switch the theme.

Could you please consult your hosting company if there is an option in your hosting panel to create a staging site and ask for their guidance?

Also, please ask the hosting support to have a look into the server's DNS settings and let them verify that everything is as expected on their end.

August 14, 2024 at 6:18 pm #16072207

nativeW

After contacting the server supplier he replied the problem was with bad configuration of wpml plugin because of the automatic rules written in htaccess file because de rules are changing with the language and it's not supposed. In this way, if we change again a language, because of the rules have changed with the previous language alteration, it will give the 404 error. The rules surfing the website are always over written so changing manually doesn't solve.

Here the answer in Portuguese:

Estimada Cliente,
O servidor apenas se limita a interpretar a regras de .htaccess que são colocadas no servidor sendo que este problema nos parece algum tipo de conflito ou má configuração do plugin WPML.
As regras de .htaccess colocadas no servidor de forma automatica pelo vosso site são as seguintes:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /en/
RewriteRule ^index.php$ - [L]
RewriteRule ^zh-hans/wp-login.php /en/wp-login.php [QSA,L]
RewriteRule ^en/wp-login.php /en/wp-login.php [QSA,L]
RewriteRule ^fr/wp-login.php /en/wp-login.php [QSA,L]
RewriteRule ^de/wp-login.php /en/wp-login.php [QSA,L]
RewriteRule ^pt-pt/wp-login.php /en/wp-login.php [QSA,L]
RewriteRule ^es/wp-login.php /en/wp-login.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /en/index.php [L]
</IfModule>

Verificamos que ao navegar as regras vão sendo alteradas consoante a lingua do site, o que não é suposto e estará a gerar essa situação.

Neste momento acedemos ao fr e a regra mudou para:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /fr/
RewriteRule ^index.php$ - [L]
RewriteRule ^zh-hans/wp-login.php /fr/wp-login.php [QSA,L]
RewriteRule ^en/wp-login.php /fr/wp-login.php [QSA,L]
RewriteRule ^fr/wp-login.php /fr/wp-login.php [QSA,L]
RewriteRule ^de/wp-login.php /fr/wp-login.php [QSA,L]
RewriteRule ^pt-pt/wp-login.php /fr/wp-login.php [QSA,L]
RewriteRule ^es/wp-login.php /fr/wp-login.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /fr/index.php [L]
</IfModule>

Tal irá provocar que se alguem aceder ao /en ou outro agora terá o erro que reporta.

Estas regras não nos parecem honestamente correctas pelo que sugerimos que contactem o suporte do WPML a reportar esta situação e a pedir suporte. Tentamos modificar as regras eliminando a lingua em RewriteBase /fr/ e RewriteRule . /fr/index.php [L] porém as regras são sobrepostas ao navegar pelo site, o que não seria a partida suposto.

Sem outro assunto de momento,

Apresentamos os nossos cumprimentos.

Francisco Esteves
Coordenador Dep. Suporte On-line
(Support Team Administrator)
Sampling Line - Serviços e Internet, Lda.
PTServidor® - Hosting, Housing e Network
Av. Amália Rodrigues, Nº6 D - 2675-432 Odivelas
Linha Comercial e Administrativa: (+351) 21 409 98 02 (dias úteis das 9h00 às 13h00 e das 14h30 às 18h00, chamada para a rede fixa nacional)
hidden link | hidden link

----------------------------------------------
Ticket ID: #000049
Assunto: Erros 404 pagina não encontrada às vezes com mensagem do servidor
Estado: Fechado
Ticket URL: hidden link

August 14, 2024 at 9:42 pm #16072536

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

This is a known issue and it is not direclty caused by WPML. We have a workaround for this issue available here:

https://wpml.org/faq/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website/

Let me know if you need my assitance with applying this workaround.

August 15, 2024 at 9:23 am #16073713

nativeW

Great. Hope this solve. And yes, I need your assistance to apply. Thank you

August 15, 2024 at 3:34 pm #16075248

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

The workaround is now integrated into the functions.pho file of your child theme.

August 15, 2024 at 7:14 pm #16075901

nativeW

However the error persist. And there is one thing in the queue that don't dismiss in spite of saying it should take 1 min.

August 15, 2024 at 9:00 pm #16076246

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

This seems to related to the issue that we already fixed on our second ticket.

Now, when revising the functions.php file of you Child Theme, this workaround is still missing.

I am not able to edit files on your server so I tried to download, edit and upload the functions.pgp file, but it neither worked.

This code needs to be added to the functions.php file of your Child 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;
}
August 16, 2024 at 12:51 am #16076436

nativeW

It didn't worked on the child theme which gave a critical error, but I tried the same code in the parent theme and now I don't get any 404 error in any page so thank you Andreas.

Now I just noticed that the plugin Amelia for reservations is not being translated but tomorrow I will try to check it out if there is some strings missing translations.

Finally, I want to check with you if the two warnings in the status (image above) of woo commerce multilingual are ok or is something missing because when I look at endpoints they seem all translated.

Captura de ecrã 2024-08-16, às 01.47.36.png
August 16, 2024 at 2:10 am #16076542

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Right, those WCML config issues needed to be fixed and I have been able to fix a few of them now.

The issue that remains is that it seems that the product permalink base is not translatable. I tried translating it, but no success.

This would mean, that for example in German the products would use (reserve) as slug base, instead of "produto".

This is something and need to be investigated further and needs proper testing.

Please take note that we always handle only one issue per ticket and as your latest requests are not direclty related to the issue handled inside this ticket, I would like to encourage you to open a seperate ticket for any further issue.

Our support team will or myself will attend you as soon as possible.

I hope for your understanding!