Override index.php for a subdirectory

Francis Daly francis at daoine.org
Tue Dec 17 20:48:37 UTC 2013

On Tue, Dec 17, 2013 at 12:26:16PM +0100, Lorenzo Milesi wrote:

Hi there,

> I need to override default index file for a subdirectory only.


Make sure that requests for this subdirectory only are handled in a
specific location block.

Set the default index file within that location block.

> server {
>     listen 80 default_server;
>     server_name localhost;
>     location / { 
>     location ~ \.php$ {
>     location ~ /\.ht {
> }

> server {
>     location ~ /work/management_site/ {
> }

> But doesn't work. 
> How can I accomplish that?


When a request comes in, first the one server{} to handle it is chosen.

Then the one location{} to handle it within that server{} is chosen.

You will probably want your new location, which will probably use "^~",
to be in the same server{} block as the rest of your configuration.

Francis Daly        francis at daoine.org

More information about the nginx mailing list