Reputation: 161
I am trying to do a redirect in my nginx config from SubDomain.domain.com to domain.com/SubDomain. The problem I am facing is that when i try SubDomain.domain.com nginx redirects it to domain.com/subdomain and misses the uppercases. How can i achieve that?
Here is my nginx config block:
if ($http_host ~* "^(.+)\.domain\.com$") {
set $subdomain $1;
rewrite (.*) http://domain.com/$subdomain$1;
}
Upvotes: 0
Views: 2314
Reputation: 6864
The variable is always lowercase.
$host
This variable is equal to line Host in the header of request or name of the server processing the request if the Host header is not available.
This variable may have a different value from $http_host in such cases: 1) when the Host input header is absent or has an empty value, $host equals to the value of server_name directive; 2)when the value of Host contains port number, $host doesn't include that port number. $host's value is always lowercase since 0.8.17.
$http_HEADER
The value of the HTTP request header HEADER when converted to lowercase and with 'dashes' converted to 'underscores', e.g. $http_user_agent, $http_referer...;
Source: http://wiki.nginx.org/HttpCoreModule#.24host
Upvotes: 1