Welcome! Log In Create A New Profile

Advanced

Re: -e vs -f and -d

Maxim Dounin
December 11, 2017 11:12AM
Hello!

On Mon, Dec 11, 2017 at 09:51:51AM -0500, drook wrote:

> Hi,
>
> Considering that I don't have symbolic links why do these configs work
> differently ?
>
> ===config one===
> if (!-f $request_filename) {
> rewrite ^/(.*)$ /init.php;
> }
> if (!-d $request_filename) {
> rewrite ^/(.*)$ /init.php;
> }
> ===config one===
>
> This one above works, rewrite happens.

This will rewrite all requests, since you have two independant
cases when a rewrite happens:

- rewrite if the requested resource is not a file;
- rewrite if the requested resource is not a directory;

Since no resource can be a file and a directory at the same time,
rewrite always happens. That is, this configuration will rewrite
anything, including requests to existing files and directories.

> Being changed to this it stops working, all other lines left intact:
> ===config two===
> if (!-e $request_filename) {
> rewrite ^/(.*)$ /init.php;
> }
> ===config two===

This will not rewrite resources which are either a file, or a
directory. Everything else will be rewritten. That is, this
configuration will not rewrite requests to existing files and
directories.

See here for more information on rewrite module directives and
their execution:

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

In particular, "rewrite_log on;" might be helpful if you want to
better understand what happens in your configuration.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

-e vs -f and -d

drook December 11, 2017 09:51AM

Re: -e vs -f and -d

Maxim Dounin December 11, 2017 11:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 168
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