在lighttpd 上将 .cn .jp .ch .eu .fr 重定向到domain.com
我想将多个域重定向到我们的网络地址。
域名具有以下扩展名:
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的正则表达式有问题。 (*) 毫无意义。我认为您更熟悉 glob 语法。请记住:
基本上
'.'
表示任何内容,而'*'
表示该任何内容零次或多次。所以我猜你想要:请注意,普通点需要转义
'\.'
因为'.'
表示任何字符。另外,请记住,在 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:
Basically
'.'
means anything and'*'
means zero or more times of that anything. So I guess you want: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 theurl.redirect
part, not in the$HTTP["host"]
part!