We have currently a wildcard vhost accepting all domain request.
I want to redirect
subdomain.domain.com
to www.subdomain.domain.com
so my wildcard will answer
One exception, I dont want to redirect www.domain.com
to www.www.domain.com
How to achieve that ? I've put together (outside the wildcard block) but it's not dealing with the exception and not sure about the variable thing
if ($http_host ~ (.*).domain.com) {
set $test P;
}
if ($http_host != www.domain.com) {
set $test "${test}C";
}
if ($http_host != www.*.domain.com) {
set $test "${test}D";
}
if ($test = PCD) {
rewrite ^(.*)$ www.%1.domain.com$1 permanent;
}
Thanks
I would use this: