I’m trying to run the PHP web application Opensupports with Caddy rather then Apache2 which they have htaccess files for. I don’t quite understand the htaccess files well enough to be able to properly convert them to the caddy rewrite formats.
I’ve tried a few of the Caddy examples without much luck. After that I decided to try and find similar conversions done in other threads and modify them to hopefully achieve what I need, also without success.
These are actually some of the most common .htaccess files out there. In plain English, they say:
Enable URL rewriting
Only rewrite if the request URI isn’t an actual file
Only rewrite if the request URI isn’t an actual directory
Only rewrite if the request URI doesn’t start with api/ (it might also start with /, too)
Rewrite to /index.php
This behaviour is pretty easily replicable. In a Caddyfile it looks like this:
rewrite {
if {path} not_starts_with /api/
to {path} {path}/ index.php
}
Oddly though, the one under the /api folder does the exact same thing. If we remove the not_starts_with check in the above example, it will pull double duty, covering both .htaccess files.
Thanks a lot for your explanation! Although for some reason it’s saying the following: Invalid operator not_starts_with perhaps not_starts_with is deprecated?