Welcome! Log In Create A New Profile

Advanced

try_files on every parent folder, not only root

Posted by manwe 
try_files on every parent folder, not only root
December 27, 2012 05:43AM
Hi *.

I'm new with nginx, but I love it already. I have few working servers so far and learning something new every day. But for this problem I cannot find any solution.

Let's assume I have few apps on server, localhost for example:

http://localhost/app1/
http://localhost/app2/trunk/
http://localhost/app3/branches/3.14/

Folders for apps tend to change from time to time. In every app folder there's an main index.php file. In Apache I had .htaccess which for every not found folder/file was using mod_rewrting to pass url to index.php. When I have one app and server { } is set to root I just use location / { try_files $uri $uri/ /index.php?$args; }

But that cannot work here, I don't have /index.php, I have /app1/index.php and /app3/branches/3.14/index.php and so far. So how can I tell nginx to look for closest index.php in parent folders until it finds one? I'm guessing try_files ../index.php ../../index.php ../../../index.php would work, but it's definitely not pretty.
Re: try_files on every parent folder, not only root
December 27, 2012 05:45AM
Example problematic url is http://localhost/app2/trunk/skin/default/red/styles/compressed/style.css. It should call http://localhost/app2/trunk/index.php
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 194
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready