Nginx config rewriting subdomain name to 1st URI segment

Posted by tim peterson on Server Fault See other posts from Server Fault or by tim peterson
Published on 2012-08-29T19:31:52Z Indexed on 2012/08/30 3:40 UTC
Read the original article Hit count: 529

I'm unable to do the following nginx.conf rewrite:

test.mysite.info 

to:

mysite.info/test

here's what i've tried:

server {
  server_name test.mysite.info;
  rewrite ^  https://mysite.info/test/$request_uri;
}

I know my DNS (Route53 AWS) is correct b/c:

  1. test.mysite.info redirects to mysite.info (just not mysite.info/test)
  2. I have an Apache server handling mysite.com which using .htaccess I can rewrite test.mysite.com to mysite.com/test.

I haven't changed anything else from the default nginx.conf installation so I'm totally confused as to why such a simple thing isn't working. Here is my full nginx.conf file if that is helpful.

© Server Fault or respective owner

Related posts about dns

Related posts about nginx