Trying to understand an Apache rewrite

54 views Asked by At

It's been a while since I have used Apache and I just can't wrap my mind around this rewrite even after a documentation refresher. Can anyone explain to me how this rewrite flows / translates to english? I am trying to convert to Nginx using try_files (and no evil ifs) but it seems to me the second sequence would never be reached by these rules:

RewriteCond %{REQUEST_URI} !dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.* dispatch.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
1

There are 1 answers

0
Alexey Ten On

First rewrites requests for non-existent files to dispatch.php.

Second appends .php suffix if file with .php suffix exists. But it seems to me, that you'll never get to second part.