Django
使用 lighttpd 和正則表達式將所有子域重定向到主域
是否可以將所有重定向
*.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", ) }
基本上這個解決方案出了點問題,因為它傾向於在訓練斜線後殺死所有文件。
我認為這應該可以完成工作:
server_modules = ( # your modules "mod_redirect", ) $HTTP["host"] =~ ".*\.example\.com" { url.redirect = ( "^/(.*)" => "http://example.com/$1" ) }