在lighttpd 上将 .cn .jp .ch .eu .fr 重定向到domain.com

发布于 2024-08-18 04:48:06 字数 512 浏览 1 评论 0原文

我想将多个域重定向到我们的网络地址。

域名具有以下扩展名:

  • cn
  • jp
  • ch
  • eu
  • fr

www.domain.fr 应指向 www.domain.com - sub.domain.fr 应指向 sub.domain.com 并且扩展名后的路径应保持不变,以便www.domain.fr/foo 指向 www.domain.com/foo

FR 只是一个例子。它应该适用于所解释的方式的所有扩展。对我来说,我们是否明确写入 (cn|jp|ch|eu|fr) 或者是否设置通配符并不重要。

我尝试了以下方法,但没有成功:

$HTTP["host"] =~ "(*.)?domain\.(*)(/*)?$" {
     url.redirect = ("^/(.*)" => "http://%1.domain.com%3")
}

感谢您的帮助!

I would like to redirect several domains to our dotcom address.

The domains have the following extensions:

  • cn
  • jp
  • ch
  • eu
  • fr

www.domain.fr should point to www.domain.com - sub.domain.fr should point to sub.domain.com and the path after the extension should stay intact so that www.domain.fr/foo points to www.domain.com/foo

FR is just an example. It should work for all extensions the way explained. For me, it does not matter wheter we explicitly write (cn|jp|ch|eu|fr) or if set a wildcard.

I tried the following which did not work:

$HTTP["host"] =~ "(*.)?domain\.(*)(/*)?$" {
     url.redirect = ("^/(.*)" => "http://%1.domain.com%3")
}

Thanks for your help!

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

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

发布评论

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

评论(1

挽袖吟 2024-08-25 04:48:06

你的正则表达式有问题。 (*) 毫无意义。我认为您更熟悉 glob 语法。请记住:

* (in glob) === .* (in regexp)

基本上 '.' 表示任何内容,而 '*' 表示该任何内容零次或多次。所以我猜你想要:

$HTTP["host"] =~ "(.*\.)?domain\.(.*)$" {
    url.redirect = ("^(/.*)" => "http://%1.domain.com$1")
}

请注意,普通点需要转义 '\.' 因为 '.' 表示任何字符。

另外,请记住,在 lighttpd 语法中,$HTTP["host"] 变量不包含任何路径。您在 url.redirect 部分中进行路径提取,而不是在 $HTTP["host"] 部分中!

Something's wrong with your regexp. (*) makes no sense whatsoever. I think you're more familiar with glob syntax. Just remember:

* (in glob) === .* (in regexp)

Basically '.' means anything and '*' means zero or more times of that anything. So I guess you want:

$HTTP["host"] =~ "(.*\.)?domain\.(.*)$" {
    url.redirect = ("^(/.*)" => "http://%1.domain.com$1")
}

Note that plain dots need to be escaped '\.' because '.' means any character at all.

Also, remember that in lighttpd syntax, the $HTTP["host"] variable does not contain any path. You do the path extraction in the url.redirect part, not in the $HTTP["host"] part!

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