Welcome! Log In Create A New Profile

Advanced

Re: index.php in folders.

B.R.
June 07, 2013 01:56AM
Hello,

On Fri, Jun 7, 2013 at 1:24 AM, Steve Holdoway <steve@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.*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

index.php in folders.

GreenGecko June 07, 2013 01:26AM

Re: index.php in folders.

B.R. June 07, 2013 01:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready