Redirect one of two domains on one WordPress installation

I have to domains: mydomain.dk and mydomain.de. Both are showing the same page in danish. I have a plugin that takes care of the languages, but I need to connect the .de domain to the german ‘language layer’.

How can I redirect mydomain.de to mydomain.dk/?lang=de. The mydomain.dk must stay as it is.

Read More

Thanks in advance!

Related posts

Leave a Reply

1 comment

  1. You could check the contents of the $_SERVER['REQUEST_URI'] array when the site is loaded, by placing the conditional checking logic in your header.php file of your site and then redirect the user to the appropriate language from there.

    For example in header.php add:

    $incomingUrl = $_SERVER['REQUEST_URI'];
    if($incomingUrl == 'mydomain.dk') {
      wp_redirect(URL FOR THIS LANGUAGE);
      exit;
    } else {
      wp_redirect(URL FOR THE OTHER LANGUAGE);
      exit;
    }
    

    The PHP manual page can also give you more information on the $_SERVER global array here: http://php.net/manual/en/reserved.variables.server.php

    Hope this helps.