Question

In Lighttpd, how would I express:

"if folder or file exists then navigate to it, else do rewrite rules below"

In Apache this worked well:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

Many thanks,

Mike

Was it helpful?

Solution

There isn't a mechanism like that in lighttpd. You can only check if a file doesn't exist. That means whatever rules you have after:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

Will need to go into a block like this:

url.rewrite-if-not-file = (


)

edit: added equals sign

Because if the mod_rewrite rules that you have in your question doesn't get executed (which stops rewriting if the request is for a file/directory that exists), that means the request is for a file/directory that doesn't exist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top