Skip Navigation

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

Problem:
The client was experiencing an issue where clicking on the home URL in the Spanish language version of their site was redirecting to an incorrect, irrelevant page.
Solution:
First, we verified that the homepage URL for the Spanish language should not include the default language slug "es". We then suggested the client to check for possible redirections caused by other plugins or custom code. To diagnose the issue, we recommended:
1. Deactivating all non-WPML plugins.
2. Switching to a standard WordPress theme.
It is important to back up the database and website before making these changes.
After further investigation on a local copy of the client's site, we determined that the issue was not related to WPML but rather a WordPress redirection issue. We provided a code snippet to add to the

functions.php

file in the theme folder to fix the issue:

remove_action('template_redirect', 'redirect_canonical');

We advised the client to apply this code to their site and to ensure a backup is made before proceeding.

Please note that this solution might be irrelevant if it's outdated or not applicable to your case. If you're still experiencing issues, we highly recommend checking related 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 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 5 replies, has 2 voices.

Last updated by gustavoF-11 5 months, 3 weeks ago.

Assisted by: Long Nguyen.

Author Posts
April 8, 2024 at 3:47 am #15492295

gustavoF-11

Hi Laura,

I have another issue since I installed wpml in this website:

When click on home url:
hidden link

...takes me to another page which is not relevant:
hidden link

what can be wrong?

April 8, 2024 at 3:55 am #15492298

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Gustavo,

Here is the new ticket. I see the homepage in the Spanish language is hidden link, without the default language slug "es". So the URL hidden link is not valid. Can you please recheck this?

Also, the redirection could be made by another plugin or block of code on your site. I suggest you enable a minimal environment as below and see how it goes.

- Deactivate all non-WPML plugins.
- Switch to a standard theme of WordPress.
❌ IMPORTANT: Please backup your database and website before proceeding ❌

Looking forward to your reply.
Thanks

April 8, 2024 at 11:08 am #15493799

gustavoF-11

Hi,
I followed all the mentioned steps:

-deactivate all plugins, including non-wpml
-switch to standard theme

nothing new happened, as url
hidden link

...shows another page:
hidden link

but I found a solution in .htaccess:

Redirect 301 /es hidden link

April 9, 2024 at 1:20 am #15496376

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I see the solution works on your site, redirect the URL hidden link to hidden link

If you want to investigate the issue further, I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to have a testing site where the issue is replicated. Your next reply is set to private to share the info.

❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: https://wordpress.org/plugins/duplicator/

I would need your permission to de-activate and re-activate Plugins and the Theme to change configurations on the site if needed. This is also a reason the backup is critical.

Looking forward to your reply.
Thanks

April 10, 2024 at 2:24 am #15502006

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I take a backup of your site and restore it on my localhost to investigate the issue. Even though I deactivate all plugins (including WPML) and switch to a WordPress theme, the issue persists.
So I think it could be a redirection issue of WordPress itself, not WPML.

Following this topic https://wordpress.stackexchange.com/questions/71927/how-to-prevent-automatic-redirection-of-404-errors-and-incorrect-urls
I add the code below to the file functions.php in the theme folder and that fixes the issue.

remove_action('template_redirect', 'redirect_canonical');

You can try to apply it on your site and let me know if it helps.
❌ IMPORTANT: Please backup your database and website before proceeding ❌

Looking forward to your reply.
Thanks

April 10, 2024 at 4:44 am #15502055

gustavoF-11

That makes sense, thanks for your support 🙂

gustavoF-11 confirmed that the issue was resolved on 2024-04-10 04:45:27.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.