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 thread is resolved. Here is a description of the problem and solution.

Problem:
Yoast redirect not working for URL with a trailing slash '/'

Solution:
The issue is fixed with a temporary work around
wp-content/plugins/sitepress-multilingual-cms/classes/compatibility/wpseo/class-wpml-wpseo-redirection.php

approximately on line number 15

replace the code

if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url ){

With

if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url || $redirection['origin'] . '/' === $url || '/' . $redirection['origin'] . '/' === $url ){

Please note, this is a temporary fix and needs to be added again until the fix is released bundled with the WPML core.

0% of people find this useful.

This topic contains 17 replies, has 2 voices.

Last updated by karimA-4 4 months, 1 week ago.

Assigned support staff: Raja Mohammed.

Author Posts
January 30, 2019 at 3:46 pm #3144805

karimA-4

Hello,

I have this redirection currently setup in Yoast: hidden link

Now if I go to hidden link the redirection works great and I am redirected, as it should, to hidden link

But if I go to hidden link (URL ending the url with a /) it goes to a 404 error: hidden link

Yoast have investigated the issue and found out that this only happens when WPML is activated. They have apparently notified your team already of this bug in order for you to fix the issue.

There are three notes mentioned in the issue:

Note One: Deactivating WPML fixes the problem.
Note Two: With WPML active, the redirect works in all cases if the old URL doesn't contain the language folder (see screenshot below).
Note Three: The problem only occurs with PHP redirects (not with .htaccess redirects).

Can you please provide an update and resolution for this issue?

Thanks!

January 31, 2019 at 6:26 am #3146441

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi There,

Welcome to our forum,

The issue is already reported and it is in our developer's queue and they are working toward a fix for the issue. As of now, we don't have an estimated time for this fix, I will closely follow up the issue and let you know as soon as I get an update from the developers.

Kind regards,
Raja

January 31, 2019 at 3:15 pm #3148526

karimA-4

Hello Raja, thank you for getting back to me. Is a fix required from WPML or Yoast's side?

Thanks!

February 1, 2019 at 5:48 am #3150454

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

The problem has already been escalated to the development team if it requires any fix in Yoast will contact them directly. unfortunately, I can not say when that will be solved exactly, but probably in one of the next updates.

For now, our recommendation is to type the original URLs in Yoast without "/".

I will let you know as soon as I have an update.

Kind regards
Raja

February 7, 2019 at 10:28 pm #3172449

karimA-4

Hello Raja, any news on this?

February 8, 2019 at 5:29 am #3173393

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thanks for reaching out,
This is still in our developer's queue and they adjust the priority of that.
I closely follow the interaction in the escalated ticket, As soon I get some update I will let you know soon.

There is a suggested workaround which our developer is still looking into it, Can I have a duplicator copy of your site so that I can test those in my local environment and let you know if that helps.
You can find the Duplicator plugin here: https://wordpress.org/plugins/duplicator/

Thanks again for your understanding and patience.
Kind regards,
Raja

February 8, 2019 at 10:47 am #3174566

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

It seems the Gdrive link is access restricted can you accept my access request. Please change the access let me know once done.

Kind regards,
Raja

February 8, 2019 at 2:04 pm #3175507

karimA-4

Done!

February 11, 2019 at 4:30 am #3180800

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks, I have received the files, I will let you know once i have an update.

Kind regards,
Raja

February 13, 2019 at 10:36 am #3193330

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Karim,

Thanks for your patience,

I have tested the workaround it works perfectly
hidden link

The workaround is a temporary solution and this needs some codes to be added to the WPML plugin file. Once you update the WPML plugin these fixes will be overridden and you might have to redo the steps again in order for the redirections to work correctly.

If it is okay for your Please add the below code in
wp-content/plugins/sitepress-multilingual-cms/classes/compatibility/wpseo/class-wpml-wpseo-redirection.php

approximately on line number 15

replace the code

if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url ){

With

if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url || $redirection['origin'] . '/' === $url || '/' . $redirection['origin'] . '/' === $url ){

Please note, this is a temporary fix and needs to be added again until the fix is released bundled with the WPML core.

Let me know if you need any assistance,

Kind regards,
Raja

February 13, 2019 at 3:17 pm #3194897

karimA-4

Hello Raja,

Thank you very much for providing us with this temp fix.

I will send it to my team to be implemented and report back with my results.

As I will need to reapply this fix every time there is an WPML update, can you kindly let me know into which version of WPML will this be bundled into the core?

February 14, 2019 at 5:12 am #3197533

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Karim,

I'm Afraid We are exactly not sure when the fix will be included in the core, there are few other issues which needs utmost priority that is being worked on and we are unsure about the exact release version until the issue is up for testing and Quality analysis.

Since this issue is also reported by Yoast themselves we will possibly include it in the core very soon.

However, You can check the release log the list of items that are fixed. or drop us a message later we would be happy to help with the status update.
https://wpml.org/download/wpml-multilingual-cms/?section=changelog

I hope the temporary fix solved your issue, Let me know if you need further assistance.

Kind regards,
Raja

February 18, 2019 at 7:40 pm #3213944

karimA-4

Raja, this seems to fix the issue on my side. Please let me know when this makes it to the core because until then I will need to manually add this code every time I update WPML. I hope it won't take too long, specially that you already have the fix for it!

Thanks,
Karim

February 19, 2019 at 5:04 am #3215149

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Karim,
Thanks for the confirmation,
I have checked with our developers, The issue here is it's a temporary workaround but needs immense testing as the fix can lead to some other conflict. we also need to check whether the fix leads to conflict with other plugins as well. We will surely keep you updated when the issue is fixed and added to the core.

Thank you very much for your understanding and patience.

Kind regards,
Raja

February 20, 2019 at 2:55 pm #3222363

karimA-4

Ok, looking forward to hear back from you soon regarding this making it to the core.