1

我有多个域指向同一个根文件夹。

该网站是多语言的。语言由会话变量设置

我有www.domain.com/index.php?lang=en (默认)

www.domain.com/index.php?lang=da(丹麦语)

我也有 www.domain.dk

我如何将www.domain.dk指向www.domain.dk/index.php?land=da

我想保持原样的 URL:

  1. 如果 .com -> url: -> http:www.domain.com

  2. 如果 .dk -> url: -> http:www.domain.dk

谢谢

4

1 回答 1

0

这个 .htaccess 代码可能会有所帮助

RewriteBase 上的 RewriteEngine /

RewriteCond %{HTTP_HOST} !^m。RewriteRule ^$ {HTTP_HOST}/index.php?land=da [R,L]

这将影响您的所有域,因为您的所有域都使用相同的 index.php。在您的 index.php 中检查您正在浏览的主机。

if($_SERVER['HTTP_HOST']=='domain.dk') {
    header("Location: www.domain.dk/index.php?land=da"); // Redirect browser

    //if there are scripts below this code insert this
    exit; // Make sure that code below does not get executed when we redirect
}
于 2012-10-24T05:08:01.473 回答