Skip Navigation

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

Problem: Multiple Domain Mapping is not working correctly with WPML

Solution: Please change your URL format settings as the ones below: WPML > Settings > Language URL format > Select "Language name added as a parameter"

0% of people find this useful.

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

Last updated by davidH-95 1 year, 8 months ago.

Assigned support staff: Alejandro.

Author Posts
January 7, 2019 at 8:09 am

davidH-95

I am trying to: We have multiple domains with the same wordpress site. The translations works fine with the main domain, but with the other domains it's always redirecting to the original (German) content. There has been an issue before redirecting always to wp-admin... this has been resolved be your team. I added the description of this problem to the resolved support thread and never got an answer. Thanks for your help:
https://wpml.org/forums/topic/custom-permalink-structure-problem/

Link to a page where the issue can be seen:
hidden link
LANGUAGE SWITCHER ON PAGE'S BOTTOM...

It's working fine here:
hidden link

January 7, 2019 at 11:26 am #3062299

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello!
Welcome to WPML Support.
I'll do my best to help you solve this issue.

I see a few things that could be creating issues on your site:

1) I see that the site is configured to show languages by directories, not domains. can you confirm this is what you want?

2) There is a plugin "Multiple Domain Mapping on Single Site" that is handling redirects, so maybe they are part of the problem, would you mind elaborating what are you using this plugin for? and can you see if by deactivating this plugin, the problem goes away?

3) You are using an outdated version of our Advanced Custom Field Multilingual plugin, please update to 1.0.1.

You see, if you check the language switcher in hidden link it does show the correct English link but as soon as you click on it, you get redirected to the german page. since you have a plugin that is handling redirections, i believe that we should start by trying to check if that plugin is the culprit (as suggested in step 2)

Please let me know how it goes.

January 7, 2019 at 1:20 pm #3062840

davidH-95

Hello Alejandro

Thanks a lot for your answer.

1) Yes it is. For each domain we want to have both english and german translations. Do you have a better solution?

2) We are using the plugin to have all domains working on the same WordPress installation. If we will deactivate this plugin, we are not able to test anymore. Because then there is only one domain left and it's working. So disabling this plugin does not help to resolve the issue.

3) I just updated the Advanced Custom Field Mulitilingual plugin.

https://wpml.org/forums/topic/custom-permalink-structure-problem/
Don't you think this could be an issue related to this, as the issue has been similar (instead of redirecting to the orgiginal post, it was redirecting to wp-admin). Maybe the snippet there was not the real solution and it could be done better?
Maybe you can also read this support thread to understand the situation better.

Thanks a lot,
David

January 7, 2019 at 4:33 pm #3063706

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi,

I'm sorry but i still don't have something clear.

- Right now you have your site structure to look something similar to this:
hidden link (translated site in English) - hidden link ( Default Language in German) and as it appears that's ok.

- The plugin that is handling redirections seems to do something like redirect "hidden link", "SiteC.com" , etc to siteA.com, right?.

- By deactivating that plugin "siteA.com" works, and if this statement is true, then that plugin is the cause of this problem.

Can you confirm this? if you can, then just let me know what you would like to achieve (the more details, the better i'll be able to understand this case and try to help you solve it), i might be able to point you in the right direction to have every setup as you wish.

Regards,
Alejandro.

January 7, 2019 at 8:53 pm #3064380

davidH-95

Hi Alejandro

The "Multiple Domain Mapping Plugin" works like this:
It maps everything within a specific Permalink structure to a specific domain.
From plugin description:
"With the plugin you can use an additional domain like http://www.productA.com to point to your site’s hidden link.
It is not only a redirection, instead the additional domain will display the content from the specified page (the additional domain will be visible in the browsers address bar)."

In our case we do have everything mapped to bergfuehrer-davosklosters.ch with the URI like this: bergsteiger-pontresina.ch/davosklosters/*

After Installing WPML everything mapped to bergfuehrer-davosklosters.ch has been redirecting to bergsteiger-pontresina.ch/wp-admin
This has been resolved here: https://wpml.org/forums/topic/custom-permalink-structure-problem/ with this Code-Snippet:

function mytheme_do_not_redirect_city_post_type( $redirect, $post_id, $query ) {
    if ( $GLOBALS['_SERVER']['HTTP_HOST'] === 'bergfuehrer-davosklosters.ch') {
       return false;
     }
    return $redirect;
    };
add_filter( 'wpml_is_redirected', 'mytheme_do_not_redirect_city_post_type', 10, 3 );

Now we have this behaviour:
bergsteiger-pontresina.ch/* (German) working
bergsteiger-pontresina.ch/en/* (English) working
bergfuehrer-davosklosters.ch/* (German) working
bergfuehrer-davosklosters.ch/en/* (English) NOT working

We are rewriting the rules here:

add_filter('rewrite_rules_array', 'mmp_rewrite_rules');
function mmp_rewrite_rules($rules) {
    $newRules  = array();
    $newRules['engadin-stmoritz/(.+)/?$'] = 'index.php?angebot=$matches[1]';
	$newRules['davosklosters/dk-(.+)/?$'] = 'index.php?post_type=page&pagename=davosklosters/dk-$matches[1]';
	$newRules['tagesskitouren/(.+)/?$'] = 'index.php?post_type=page&pagename=tagesskitouren/$matches[1]';
	$newRules['davosklosters/(.+)/?$'] = 'index.php?angebot=$matches[1]';
    return array_merge($newRules, $rules);
}

And this is where we put the destination into the permalink structure:

function wpse_5308_post_type_link( $link, $post ) {
    if ( $post->post_type === 'angebot' ) {
        if ( $website = get_field( 'primary_website',$post->ID ) )
            $link = str_replace( '%primary-website%', $website, $link );
    }

    return $link;
}

add_filter( 'post_type_link', 'wpse_5308_post_type_link', 10, 2 );

I hope this helps to understand. Let me know.
Thanks a lot,
David

January 8, 2019 at 12:40 pm #3066761

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

The problem is that right now the domain is mapping everything for the domain root but it's not mapping its directories, instead it's getting the destination page and adding it to the host root URL, which is causing the issue.

This is considered custom coding and we do not support this.
I want to point you in the right direction, though.

I checked the FAQ on the plugin and it states that it might not work with multilanguages sites and i believe the issue is because the plugin seems to only be mapping the WordPress core features such as archive pages, category pages, etc. These have all been added to the plugin rules.

In our case there could be so many potential combinations that we can't just make sure the redirections will work and a few rules won't just cut it, unfortunately and this gets even worse by not knowing how the plugin even works.

Maybe, if you configure the plugin to map the /en directory it could start working although it could then create issues with the path you're currently using.

Unfortunately we won't be able to provide you anything more than that (i would if i could, but this is way beyond the scope of our support and even a workaround could create more problems than it solves).

I would really suggest you try a simpler approach like simple redirections or even using alias (ask your hoting support if this feature is enabled and included in your hosting plan)

Regards,

Alejandro.

January 8, 2019 at 3:27 pm #3067645

davidH-95

Hey Alejandro

Thanks a lot for your detailed answer.

I've been in contact with the "Multiple Domain..." plugin author - he had an idea how it could work when changing from language directories to language subdomains.


it is only an approach but it could work like this:

use bergsteiger-pontresina.ch as your main, german domain.
use en.bergsteiger-pontresina.ch for your main, english subdomain.

map bergfuehrer-davosklosters.ch to /davosklosters (the german version)
map en.bergfuehrer-davosklosters.ch to /EnglishSlugOfDavosKlosters (the english version)

for this to work, you will need different slugs for your pages/posts in english and german, which should be possible with polylang as far as i know.

So my question now for you, can I have different slugs for my pages/posts in english and german?

Thanks for your help,
David

January 9, 2019 at 1:47 pm #3071966

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello

Yes, you can have different slugs, you just need to change your Slug settings in:
WPML > Settings >Translated documents options > Change to "Translate (this will include the slug in the translation and not create it automatically from the title)"

After that update your Slug or something in your page (add an empy element or maybe change a text) and you will have it shown in the Translation Editor of your page.

Right now your setting is generated by default from the title of the post, so the slug is actually translated and has the same name as the post/page name.

I tested another approach and it seems to be as easy as just going to WPML > Settings > Language URL format > Select "Language name added as a parameter" instead of the current option.

That will make things easier and the plugin seems to work fine with that setting.

Let me know how it goes.

January 9, 2019 at 9:15 pm #3073763

davidH-95

Hello Alejandro

Thanks a lot for your reply and your tests. Your approach with the language as parameters seems to work great with the other plugin.

Best regards,
David