wickedsunny 0 Junior Poster in Training

Hello, I did a little rewrite rule a little while ago to redirect ppl who directly access my site's image to image pages instead,

for example a person accessing www.mysite.com/i/asdf.jpg to www.mysite.com/pic/asdf

this is the rewrite rule i used :

location /i/image_(\d+).(gif|jpg|jpeg|png)$ {
  root /home/mysite/public_html;
  valid_referers www.mysite.com mysite.com;
  if ($invalid_referer) {
   rewrite ^ http://www.mysite.com/pic/$1 permanent;
  }
 }

I made a subdomain of the directory 'i' which contains all the images. so its like thsi now http://i.mysite.com/

I tried this but didn't worked :(

location i.imgzzz.com/image_(\d+).(gif|jpg|jpeg|png)$ {
  root /home/imgzzz/public_html/i;
  valid_referers www.i.imgzzz.com i.imgzzz.com;
  if ($invalid_referer) {
   rewrite ^ http://www.imgzzz.com/pic/$1 permanent;
  }
 }

Is it possible to make a rewrite like the one above so if the file is directly accessed by a different referer it will hit the same rewrite rule ?

thx :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.