Question on server_name_in_redirect

server {
listen 80;
server_name_in_redirect on;
root /var/www/html/exampel/;
index index.php index.html;

According to the wiki, this should automatically redirect any request
to to

If server_name_in_redirect is on, then Nginx will use the first value
of the server_name directive for redirects. If server_name_in_redirect
is off, then nginx will use the requested Host header.

But it didn’t work in my case. On nginx 0.8.44

So i had to use

if ($host ~* {
rewrite ^(.*)$$1 ; # $1 contains
‘/foo’, not ‘

Which is not clean and fell in the category of nginx pitfall :frowning: