Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

It looks like you forgot to specify a listen directive:

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

But wait, return may be better than rewrite:

server {
    listen      80;
    server_name test.mysite.info;
    return      301 https://mysite.info/test$request_uri;
}
share|improve this answer
    
thanks, problem solved, ugh must have been brain dead! –  tim peterson Aug 30 '12 at 3:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.