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


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:

Link to a page where the issue can be seen:
hidden link

It's working fine here:
hidden link

January 7, 2019 at 11:26 am #3062299


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

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

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


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.
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,

January 7, 2019 at 4:33 pm #3063706


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

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


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", "" , etc to, right?.

- By deactivating that plugin "" 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.


January 7, 2019 at 8:53 pm #3064380


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 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 with the URI like this:*

After Installing WPML everything mapped to has been redirecting to
This has been resolved here: with this Code-Snippet:

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

Now we have this behaviour:* (German) working* (English) working* (German) working* (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,

January 8, 2019 at 12:40 pm #3066761


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)



January 8, 2019 at 3:27 pm #3067645


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 as your main, german domain.
use for your main, english subdomain.

map to /davosklosters (the german version)
map 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,

January 9, 2019 at 1:47 pm #3071966


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

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


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


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,