可以将所有内容重定向*.domain.com
到我的domain.com
吗?
我一直在摆弄正则表达式,但没有任何运气:
$HTTP["host"] =~ ".*\.domain\.com" {
url.redirect = ("^/(.*)" => "http://domain.com/$1")
}
$HTTP["host"] =~ “domain\.com" {
server.document-root = "/var/www/servers/domain.com/awesomesite"
accesslog.filename = "/var/www/logs/domain.com/access.log"
server.errorlog = "/var/www/logs/domain.com/error.log"
fastcgi.server = (
".fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
"bin-path" => "/var/www/servers/domain.com/awesomesite/domain.fcgi",
"socket" => "/tmp/domain.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/static/" => "/var/www/servers/domain.com/awesomesite/static/",
)
url.rewrite-once = (
"^(/static.*)$" => "$1",
"^(/.*)$" => "/domain.fcgi$1",
)
}
基本上,这个解决方案出了问题,因为它倾向于删除训练斜线后带有点的所有文件。
答案1
我认为这应该可以完成这项工作:
server_modules = (
# your modules
"mod_redirect",
)
$HTTP["host"] =~ ".*\.example\.com" {
url.redirect = ( "^/(.*)" => "http://example.com/$1" )
}