Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 setting up a link tracking system, which (temporarily) involves adding /link/id/ in front of URL (like http://server/data/id/publication/id/).

rewrite data/id/(.*) http://server/$1;

The request is logged as:

ip - - [17/Nov/2011:10:07:19 +0300] "GET /data/id/publication/id.html HTTP/1.1" 302 154 "-" "UA"`

For some reason (keeping the compatibility with AWStats) it is wanted to have 200 logged instead of 302. (nginx allows to get 301 code out of box with permanent option, but thats inappropriate too)

What are my options here? Will the combination of location { } and rewrite do the job?

UPDATE: AWstats is able to understand various status codes by setting ValidHTTPCodes="200 304 301", see this question; my problem is solved, but question is still active - any way to get rewrites working without 301/302 code?

share|improve this question
up vote 2 down vote accepted

Nginx is doing a client-side redirect because the redirect target has http:// in the URL - you can do a server side redirect (nginx will reread the new URL and send the file directly, with code 200) by just having rewrite data/id/(.*) /$1;

share|improve this answer
That's an answer, thanks – kagali-san Nov 17 '11 at 13:33

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.