Skip Navigation

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: 

This topic contains 11 replies, has 2 voices.

Last updated by Raja Mohammed 2 months, 1 week ago.

Assigned support staff: Raja Mohammed.

Author Posts
January 19, 2019 at 4:07 pm #3108238

danielB-47

One of my sites broke after updating WPML, since v4.1.3 is unable to handle permalinks without trailing slash.

WPML is set to "Use directory for default language".

To reproduce the bug, go to Settings - Permalinks - choose "Custom Structure" and set it to /%postname%

Behavior in WPML v4.1.3:

Country startpage URLs are presented as /en /nl /sv (without trailing slash).

When clicked you get redirected to e.g. /en/en and get "Page not found".

Blog posts are presented without trailing slash and work as they should in different languages.

Behavior in WPML v2.0.4:

Country startpage URLs are presented as /en/ /nl/ /sv/ (with trailing slash).

If one manually enter e.g. /en WPML will redirect to /en/ and the page is shown correctly.

Blog posts are presented without trailing slash and work as they should in different languages.

Since the same issue has been reported by others in the past, I hope that your devs already have a solution for me to implement. Can I kindly have the hotfix and please let me know in which future version this fix will be implemented?

Thanks!

January 21, 2019 at 10:16 am #3111794

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

Welcome to our forum, I will be answering your queries.

I am unable to reproduce the issue in my local setup with WPML 4.1.3. The permalinks work fine following your steps. I am unable to replicate the same in a clean WordPress installation hidden link.

Could you please try to replicate the issue in the sandbox so that we can understand and identify the issue. The login to the sandbox will be provided in the next private reply. kindly let me know once you have the results with your or in case you need any further assistance please feel free to contact I will be happy to help you.

Best regards,
Raja

January 21, 2019 at 11:30 am #3112087

danielB-47

Hey Raja,

I've reproduced the bug in the sandbox environment.

I added a page and set it as Front Page and changed the WPML settings to "Use directory for default language". (Also installed the plugin Disable Gutenberg, only because I wanted to use the classic editor.)

While doing this I actually found another related issue: When permalink Custom Structure is set to /%postname%/ the root URL will be redirected to the language folder as expected, but when it's set to /%postname% it doesn't redirect.

I noticed that the browser might cache some of the redirections, so it's better to double-check the redirections with command-line tools such as curl.

Thanks!

January 21, 2019 at 1:34 pm #3112616

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

Thank you very much for your time. It seems like a bug or a known issue which i'm not sure, I will check this with our second tier of supporters, I will let you know once i have an update from them .

Kind regards,
Raja

January 22, 2019 at 6:15 am #3114949

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

The issue is already identified and reported to our developers. Our developers are still working on the issue. I would request you to use the permalinks with trailing slash until the issue is fixed and moved to WPML core.

Thanks for reporting and investigating with lot more detail, We highly appreciate your cooperation in this regard.

Kind regards,
Raja

January 22, 2019 at 1:17 pm #3116524

danielB-47

Hey Raja,

As the site in question is currently on WPML v2.0.4 the /%postname% setting (almost) works without trailing slashes. The lang folders still get trailing slashes while all other URLs are without. My client can accept to get the same behavior after the update to WPML 4.1.3.

Hence my question: While you're working on a proper fix, what code changes do I need to maintain the legacy behavior so I can update WPML without breaking the requirement from my client to use URLs without trailing slashes (except for the lang folders)?

Thanks.

January 23, 2019 at 4:40 am #3118969

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

I'm not sure the update from 2.0.4 to 4.1.3 had any other effects on your client site. if you have encountered the issue only with the trailing slash I'm afraid, I don't have any information about this now as the issue is being worked on by the developers, once I get a final update from them I can inform you about the effects of updating. Most probably this would be a smooth transition.

Updating from version 2.0.4 to version 4.1.3 may or may not break the translations which we are not sure since the upgrade has almost around 10 version updates in between.
We recommend to always keep the WPML version up to date. and do all the major updates like this in a staging/ test/ development site before applying on the live site.

I hope this answers your question, Let me know if you need any further clarification.

Kind Regards,
Raja

January 23, 2019 at 11:17 am #3120252

danielB-47

Hey Raja,

In this support thread I'd like to focus only on the language folders and WPML's unability to handle them when you set the permalink Custom Structure to /%postname% (no trailing slash). Should there be other issues after the WPML update I'll report them separately.

So this is my dilemma: I want to update WPML since I'm updating all the WP plugins and core as well. If I do the WPML update I'm unable to use URLs without trailing slashes, which is a requirement from my client.

Hence, since you can use the /%postname% setting in earlier versions of WPML (the only issue is that the language folders themselves get trailing slashes, but that's acceptable as long as all other pages are without slashes). So I want to revert the breaking code changes that your devs implemented and restore the previous functionality, otherwise I can't update WPML and have to stay with an old version.

Do you understand what I'm looking for?

Thanks!

January 23, 2019 at 2:01 pm #3120892

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

In my humble opinion, you can keep using the older version until the fix is released but i'm afraid we don't have any estimate on how soon the fix will be available.

However, There won't be any breaking changes with URL format, As far as I know, we have clients who use versions as old as 2.8 and they update to the latest and didn't report any breaking issues.

If you wish to use the latest plugin with your permalink structure.

There is a temporary workaround suggested that require slightly altering the code in WPML plugin.

In the file wp-content/plugins/sitepress-multilingual-cms/classes/canonicals/class-wpml-canonicals-hooks.php:

On line number 53 :

if ( 0 !== strpos( $actual_uri, '/' . $lang . '/' ) ) {

replace the above code with the one below

if ( 0 !== strpos( $actual_uri, '/' . $lang  ) ) {

This will fix the issue temporarily.

Recomended: Always back up your site and perform any update or workaround in staging and test site before moving it to live.

Let me know if you need any further assistance.

Kind regards,
Raja

January 23, 2019 at 2:28 pm #3121003

danielB-47

Hey Raja,

Now we're getting somewhere! This is what I'm looking for, a temp fix to use until it's fixed in the WPML core. Thank you! And please don't worry, I use staging and testing environments all day long 😀

Just did the quickest of testing and found that adding a trailing slash to the lang folder didn't redirect to the one without and also there's no redirection to the default language from the root url when "Use directory for default language" is checked. Do you have temp fixes for these issues as well or should I try to figure something out on my own?

Thanks again.

January 24, 2019 at 5:00 am #3123432

Raja Mohammed
Supporter

Languages: English (English )

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

Hi Daniel,

We don't usually suggest any modification in the core until the user is very much confident and aware of the consequences 🙂 and hence I am very much reluctant to suggest that. Glad it was a bit of help for you.

Redirecting the URL with trailing slash to the one without slash should be handled with custom code. I'm Afraid we don't have any suggestion or workaround for it.
And the same applies to your second request "redirect default language from the root url".

Please note that when the Use directory for default language option is set on the WPML -> Languages page, a root page must be used which doesn't have any language value. it won't redirect to language which is expected behavior.
https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/#what-is-a-root-page-and-do-i-need-one

However, you can add the redirect rule to that root page to display default language URL.

Kind regards,
Raja

August 5, 2021 at 7:14 am #9347257

Raja Mohammed
Supporter

Languages: English (English )

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

Hello there,

The issue is not relevant anymore and should be already fixed in one of our latest plugin updates, If not already done Please update all the WPML plugins to the latest version.

I am marking the ticket as resolved, Feel free to reach us if you still need further assistance with our plugin.

Regards
Raja