Webmasters Stack Exchange is a question and answer site for pro webmasters. 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

If I'm not wrong,
location = / {} means "only the / folder, not the files inside, not the subfolders"
location ~ / {} means "the / folder, all the files inside, all the subfolders and their subfiles"
But what it means:
location ^~ / {}?
I found this configuration in the web, but I wasn't able to google an answer.
I found it in a tutorial while I was trying to protect with htpasswd a folder and everything inside of it. However location ~ / did the job, while even if location ^~ / protected everything as well, it did not let the php pages to work correctly.

share|improve this question
up vote 1 down vote accepted

Quote from nginx documentation:

If the longest matching prefix location has the “^~” modifier then regular expressions are not checked.

So, if the location matches / location, then locations using regex aren't evaluated. This causes the effect you described, that is, PHP scripts stop working, because PHP scripts are generally defined using a regex location block.

share|improve this answer
That is what I was unable to find, thanks Tero. – Netscreever Mar 14 '14 at 13:30

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.