将 en.example.com 重定向到 example.com/index.php?language=en

发布于 2024-08-16 06:55:18 字数 410 浏览 8 评论 0原文

我想要将以下开头的地址重定向

en.example.com/somefile.php

example.com/somefile.php?language=en

:在lighttpd中使用mod_rewrite模块。直到现在我才明白:

$HTTP["host"] =~ "^en\.(.*)\.com$" {
        url.rewrite-once = (
                "^/(.*)"
                =>
                "/$1?language=en"
        )
}

但这似乎不起作用。要做什么才能使这项工作有效?

I would like redirect addresses that start with:

en.example.com/somefile.php

to:

example.com/somefile.php?language=en

Using mod_rewrite module in lighttpd. Until now I got this:

$HTTP["host"] =~ "^en\.(.*)\.com$" {
        url.rewrite-once = (
                "^/(.*)"
                =>
                "/$1?language=en"
        )
}

But this does not seem to be working. What to do to make this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅唱ヾ落雨殇 2024-08-23 06:55:18

试试这个:

$HTTP["host"] =~ "^en\.([^/.]+)\.com$" {
    url.rewrite-once = (
        "^/([^?]*)(\?(.*))?" => "http://%1/$1?language=en&$3"
    )
}

Try this:

$HTTP["host"] =~ "^en\.([^/.]+)\.com$" {
    url.rewrite-once = (
        "^/([^?]*)(\?(.*))?" => "http://%1/$1?language=en&$3"
    )
}
待"谢繁草 2024-08-23 06:55:18

试试这个

$HTTP["host"] !~ "^(en|fr)\.([^.]+\.com)$ {
    url.rewrite-once = (
      "^/(.*)" => "http://%2/$1&language=%1" 
    )
  }

这应该重写子域 en。和/或神父。到 URL 字符串完整的任何域(包括 TLD),并附加语言参数。

示例:

http://en.example.com            -> http://example.com/&language=en
http://fr.example.com/directory/ -> http://example.com/directory/&language=fr

Try this

$HTTP["host"] !~ "^(en|fr)\.([^.]+\.com)$ {
    url.rewrite-once = (
      "^/(.*)" => "http://%2/$1&language=%1" 
    )
  }

This should rewrite subdomains en. and/or fr. to whatever domain (including the TLD) with the URL string intact, and append the language parameter.

Examples:

http://en.example.com            -> http://example.com/&language=en
http://fr.example.com/directory/ -> http://example.com/directory/&language=fr
蘑菇王子 2024-08-23 06:55:18

尝试以下..如果它适合您..

$HTTP["host"] =~ "^en.([^.]+.com[a-z0-9-]+.php)$" {
url.rewrite-once = (
“^/(.*)”
=>
“/$1?语言=en”

}

try following.. if it works for you..

$HTTP["host"] =~ "^en.([^.]+.com[a-z0-9-]+.php)$" {
url.rewrite-once = (
"^/(.*)"
=>
"/$1?language=en"
)
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文