Dont Rewrite if File Exists. Lumen .htaccess to caddyfile

I thought this worked for a php lumen site

     #Rewrite for Lumen
    rewrite / {
     r (.*)
     to /index.php
     
    }

this rewrites all requests to index.php However the htaccess file has the other 2 lines

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

apparently these mean if the directory exists or if the file exists then dont redirect.

Is there a way I can write a rewrite block in Caddyfile that will not rewrite if the file or folder exists?

I think I have solved this

    rewrite  {
      to {path} {path}/  /index.php
    }

seems to cover both eventualities

I will update https://github.com/caddyserver/examples/blob/master/lumen/caddyfile

1 Like