NGINX redirect subdomain to sub directory

view story

http://serverfault.com – I know this must have been answered a million times but I can't seem to get it to work I would like to redirect a subdomain to a subdirectory. I am currently using server { server_name sub.domain.com; rewrite ^(.*) http://www.domain.com/sub-directory permanent; } If I navigate to sub.domain.com I am redirected to http://www.domain.com EDIT Here's my full config. I have changed the actual domains and sub directories server { server_name forum.domain.com; rewrite ^(.*) http://www.domain.com/forum permanent; } server { # Listen on port 80 as well as post 443 for SSL connections. liste (HowTos)