0

Nginx v 1.4.6

autoindex off;

In an application having no central routing end-point, and for directories w/in the structure that have no index.* at all, I want to external redirect rather than 403 Forbidden or internal redirect.

app-root/
    app-core/
    config/
    lib/
    modules/
    templates/
index.php

Given the above, if none of app-core/ lib/ modules/ templates/ have an index.*, with no server { location {}} configuration coverage, any request to them results in a 402 forbidden response. Yucky.

With this config, I can internally redirect to an actual index.

location ~* ^/(app-core|config|lib|modules|templates)/$ {
    index /;
}

So an request to http://localhost:xxxx/lib/ serves the app-root/index.php shown above. Fair enough but I think it could be better.

I would rather issue a 303 See Other and redirect to http://localhost:xxxx/ but I cannot figure out how to make it work.

1 Answer 1

1

It should work with this:

location ~* ^/(app-core|config|lib|modules|templates)/$ {
    return 303 http://localhost:xxxx/;
}
1
  • actually i ended up with: return 303 $scheme://$host:$server_port/;
    – CNSKnight
    Jul 19, 2015 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .