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

According to the varnish documentation, the regsub method should not result in a 301 redirect. Yet that is what seems to be happening in my case (that is, the url actually changes in the browser).

This is what my config looks like:

sub vcl_recv {
    set req.url = regsub(req.url, "^/event/([-\w]+)/(.*)/$", "/event/\1");

(/event/testevent/1234/ is redirected to /event/testevent)

Behind, I've got nginx and django varnish -> nginx -> uwsgi -> django

share|improve this question
up vote 1 down vote accepted

Oh, I see what happened... Django was appending a slash to the url an doing a redirect.

This does the trick:

set req.url = regsub(req.url, "^/event/([-\w]+)/(.*)/$", "/event/\1/");
share|improve this answer

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.