index.php in folders.

B.R. reallfqq-nginx at yahoo.fr
Fri Jun 7 05:54:38 UTC 2013


Hello,

On Fri, Jun 7, 2013 at 1:24 AM, Steve Holdoway <steve at greengecko.co.nz>wrote:

> Is there a simple config I can use to check for an index.php in
> subfolders?
>
> It was my understanding that if I used
>
>         index index.php;
>
> in the server block, and
>
>         try_files $uri $uri/ /index.php;
>
> in location / {} that it would look for $uri/index.php. But I do seem to
> be misunderstanding.
>
​
Your try_files directive is only working if your content is served by the
location block where it is placed.
If another location block serves content, the try_files directive won't
apply. I don't know the default behavior then, but I guess that you either
need to specify a directory by ending the URI with a trailing slash
(directory) or specify the 'index.php' file at the end of it.

I suggest you move the try_files directive up in the hierarchy, thus in the
containing server block.
​


>
> Help!
>
​
I also suggest that you add something after the last part of the try_files
directive or replace it with a proper handler for missing files.
In your example, you specified that requests missing files should be
redirected to '/index.php'. That can end-up in a loop-hole if there is no
index.php file at root.

I suggest you use something like:
try_files $uri $uri/ /index.php =404;

Please read the documentation of the try_files
directive<http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files>for
more information.​
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130607/2af75231/attachment-0001.html>


More information about the nginx mailing list