Hi @TrAnn3l, welcome to the Caddy community. Your avatar is my favourite PD2 mask!
Rewrite comes with regex capabilities, so you could remove the index.php part that way.
Going off your example: https://example.com/index.php/apps/theming/img/core/filetypes/folder-external.svg?v=13
rewrite {
if_op or # proceed if any of the following is true:
if {path} ends_with svg
if {path} ends_with gif
if {path} ends_with png
if {path} ends_with html
if {path} ends_with ttf
if {path} ends_with woff
if {path} ends_with ico
if {path} ends_with jpg
if {path} ends_with jpeg
r ^/index.php/(.+)$
to /{1}
}
It is almost working, only one images is not loading (404 not found): https://example.com/index.php/apps/theming/img/core/filetypes/folder.svg?v=13
And again, when i manually remove the index.php it is loading. I have no idea why the rewrite is not triggering.
I put your rewrite first, so there should be nothing intercepting.
In addition, i changed your code a little bit and used the ext directive
Update:
Adding /index.php?{1} to the to directive fixed it
My code looks now like:
example.com {
root /var/www/nextcloud
log /var/log/nextcloud_access.log
errors /var/log/nextcloud_errors.log
fastcgi / 127.0.0.1:9000 php {
env PATH /bin
}
rewrite {
ext .svg .gif .png .html .ttf .woff .ico .jpg .jpeg
r ^/index.php/(.+)$
to /{1} /index.php?{1}
}
rewrite {
r ^/index.php/.*$
to /index.php?{query}
}
# client support (e.g. os x calendar / contacts)
redir /.well-known/carddav /remote.php/carddav 301
redir /.well-known/caldav /remote.php/caldav 301
# remove trailing / as it causes errors with php-fpm
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)$
to /remote.php/{1}
}
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)$
to /remote.php/{1}/{2}
}
rewrite {
r ^/public.php/(.+?)(\/?)$
to /public.php/(.+?)(\/?)$
}
# .htaccess / data / config / ... shouldn't be accessible from outside
status 403 {
/.htacces
/data
/config
/db_structure
/.xml
/README
}
header / Strict-Transport-Security "max-age=31536000;"
}
Till now, nextcloud is the only site which still requires a lot of rewrites.
I will make a PR to update the example.