Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

A stupid question perhaps, but I can't seem to find good documentation or examples for this...

When you're using location blocks to filter incoming requests, do you do your rewrite from the matched location or from the start of the request?

An example:

location ^~ /category/ {
    rewrite ^/category/paid-search-news/?$ /tag/paid-search permanent; # this,
    rewrite ^paid-search-news/?$ /tag/paid-search permanent; # this,
    rewrite paid-search-news/?$ /tag/paid-search permanent; # or this?
share|improve this question
up vote 3 down vote accepted

From the start of the request. There is documentation on that here.

location /download/ {
  rewrite  ^(/download/.*)/media/(.*)\..*$  $1/mp3/$2.mp3  break;
  rewrite  ^(/download/.*)/audio/(.*)\..*$  $1/mp3/$2.ra   break;
  return   403;
share|improve this answer

The documentation implies that the full URL is matched (i.e. your first example).

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.