Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


here's what i've tried:

server {
  rewrite ^$request_uri;

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

  1. redirects to (just not
  2. I have an Apache server handling which using .htaccess I can rewrite to

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
up vote 2 down vote accepted

It looks like you forgot to specify a listen directive:

server {
    listen      80;
    rewrite     ^$request_uri;

But wait, return may be better than rewrite:

server {
    listen      80;
    return      301$request_uri;
share|improve this answer
thanks, problem solved, ugh must have been brain dead! – tim peterson Aug 30 '12 at 3:23

Your Answer


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.