Resolved
Reported for: WPML Multilingual CMS 4.6.9
Resolved in: WPML 4.6.10
Overview of the issue
In a multisite WordPress network or a single install with a sub-folder installation, activating the Use directory for default language option leads to incorrect redirection for taxonomy archives, resulting in a 404 error.
Workaround
Please, make sure of having a full backup of your site before proceeding.
You can try to install the latest beta release for WPML (v 4.6.10)
Or try the following:
- Open …/wp-content/plugins/sitepress-multilingual-cms/classes/canonicals/class-wpml-canonicals-hooks.php file.
- Look for line 104.
- Change:
$currentUri = substr( $currentUri, strlen( $path ) );
- For:
$currentUri = '/' . ltrim(substr( $currentUri, strlen( $path ) ), '/');
I have same issue, and NOT multisite active.
this patch worked for me, hopefully
Thank you very much for your feedback. Our developers are aware of this issue and working in a future release with a fix for it.
Regards
On a multisite installation is still redirecting to a 404
If the workaround here provided didn’t help, please open a chat in our assistance channel.
It may be a different issue that the one reported here.
I am using multisite with subfolders and I do have this /enen/ problem occuring when calling a category page.
https://domain.com/en/category/x/ gets https://domain.com/enen/category/x/
I tried your patch line and it does change the behaviour, but in a bad way: now it always redirects to the home page https://domain.com/en/
Sorry, I’m not a developer – I’m just messing around with code …
I found, that in /wp-content/plugins/sitepress-multilingual-cms/classes/canonicals/class-wpml-canonicals-hooks.php
In line 108 it checks if there is ‘/’.$lang in $currentUri
if not in line 110 it adds up to $home_url . ‘/’ . $lang . $currentUri
In my case $currentUri was set to ‘en/category/x/’ —> $lang is already there, only the slash is missing.
now it adds up $home_url .’/’ . ‘en’ . ‘en/category/x/’
This seems to be the reason for my problem.
Could please you have a look into this?
I have to correct my former statements: your patch did work!
My redirect seems to have other reasons- it was not related to WPML.
Thanks for the patch and sorry for my former confusing messages.
No worries, we are glad to know that the patch worked and you figured out what was missing in your website. 🙂
Hello everyone,
This issue should be solved with WPML 4.6.10.
Regards