<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body>
<p>I have read documentation from several sources, and there is still 1 detail about nginx configuration that I do not fully understand, and would like some additional guidance. In the nginx location configuration, how does one handle locations that would match multiple criteria, but nginx can only match on one?</p>
<p>For example, lets say I have a php application and I am using php-fpm, which has an admin interface that I want to protect using htaccess. I would have location directives in my config with the following contents:</p>
<p>location ~* /admin/ {<br /> auth_basic "Restricted";<br /> auth_basic_user_file htpasswd;<br /> }</p>
<p>location ~* \.php$ {<br /> try_files $uri =404;<br /> fastcgi_index index.php;<br /> fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;<br /> include fastcgi_params;<br /> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br /> fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br /> }</p>
<p><br />From my understanding of how nginx processes the config file, it would match the /admin/ regex first, but what if the files contained in this directory are PHP scripts? Since the first location matches in my config, I believe that the second location with the PHP redirect is never processed?</p>
<p>Thanks in advance,</p>
<p>-JB</p>
<div> </div>
</body></html>