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 just installed nginx up and running for serving static content on my site. it works great but the apache rewrite rule about images (ofcourse) stoped working.

and i don't have an idea how to convert and in whcih file to put .

This is what i was using on apache :

RewriteCond %{HTTP_REFERER} !^http://(www\.)?*$ [NC]
RewriteRule i/image_(\d+)\.(jpg|jpeg|gif) pic/$1 [L]

Its purpose is to redirect directly accessed images to the image page instead.

Thanks in advance :) cheers

share|improve this question
up vote 0 down vote accepted

Untested.. but you'll get a better idea

if ($http_referer ~* ""){ 
   rewrite ^/i/image_(\d+)/.(jpg|jpeg|gif)$ /pic/$1 last; 
share|improve this answer
hmm k i tried this : location /i/image_ { location ~ ^/i/image_(?<IMAGE>\d+)\.(jpg|jpeg|gif)$ { valid_referers; if ($invalid_referer) { rewrite ^ /pic/$IMAGE; } } } – Ayaz Malik Dec 3 '10 at 13:09

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.