2月 052012
 

Varnish redirect is pain.


sub vcl_recv {
  if (req.http.user-agent ~ "iP(hone|od)") {
    error 750 "Moved Temporarily";
  }
}

sub vcl_error {
  if (obj.status == 750) {
    set obj.http.Location = "http://www.example.com/iphoneversion/";
    set obj.status = 302;
    return(deliver);
  }
}

(via:Redirecting using VCL)
I just want to redirect. but should write code in two action.
This is it lack of maintenance, and I do not like.
I tried to make a vmod_redirect can be easily redirect.

If you do the same thing and just


import redirect;
sub vcl_recv {
   if (req.http.user-agent ~ "iP(hone|od)") {
      error(redirect.location(302,"http://www.example.com/iphoneversion/") , "Moved Temporarily");
   }
}

If you do not need reason phrase


import redirect;
sub vcl_recv {
   if (req.http.user-agent ~ "iP(hone|od)") {
      error(redirect.location(302,"http://www.example.com/iphoneversion/"));
   }
}

note:require enclose in error method.

download here.
libvmod-redirect


2012-02-17
change name from vmod_rewrite to vmod_redirect.

日本語の記事はこっち


 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください