So, these two, then:
- If the client requests an existing file, but with a trailing slash, redirect them to remove the slash.
- If they don’t request an existing file, serve them to the index file without redirecting.
Lets refactor a bit, then. Try something like this.
# Check for:
# 1. File without trailing slash (like -f)
# 2. Existing directory (like -d)
# Else, fall back to PHP index
rewrite {
r ^(.+?)/?$
to {1} {1}/ /index.php?{1}
}
# If we got a request with an unneeded
# trailing slash, redirect the client
# - don't redirect PHP index, though
redir {
if {uri} ends_with /
if {rewrite_uri} not_ends_with /
if {rewrite_uri} not_starts_with /index.php?
/ {rewrite_uri}
}