Equivalent to "dirname"

Pior Bastida pior at mentel.com
Mon Dec 14 23:59:26 MSK 2009


On December 14, 2009 03:20:20 pm merlin corey wrote:
> On Mon, Dec 14, 2009 at 12:09 PM, Pior Bastida <pior at pbastida.net> wrote:
> > Hello,
> >
> > I would like to check if the directory of a non existant file exist.

> The rewrite module provides a -d operator to the if directive which
> will test for a directory existence; please see
> http://wiki.nginx.org/NginxHttpRewriteModule#if .
> 
> Alternatively, if you are going to end up using the index or some
> value inside the directory if it exists, then you should consider
> using the try_files directive documented here:
> http://wiki.nginx.org/NginxHttpCoreModule#try_files .

Thank you Merlin.

I almost know all the wiki, including -d and try_files.

Here is what I need to do :

 1. try to server /poipoi/foobar
 2. if the file doesn't exist, check if /poipoi/ exist
 3. if this directory doesn't exist, return a redirect, otherwise return 404

How can I get the base directory of $request_filename ?

-- 
Pior Bastida
System Administrator
Mentel Inc
pior at mentel.com




More information about the nginx mailing list