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 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
add comment

1 Answer

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
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.