Rewrite rules for Symfony 3/4 application

I am trying to create a Caddyfile for OpenCFP, a open source PHP project that I am the main developer for. I have been unable to figure out what the rewrite rule should look like. Here is what I have so far (for local dev right now)

localhost:8080
root /Users/chartjes/Sites/opencfp/web
fastcgi / /Users/chartjes/.valet/valet.sock php
rewrite to {path} {path}/ /index.php/{path}
log access.log
errors error.log

The front page of the application loads just fine, but if I try to go to any other URL’s I am getting a 404

ie /ideas

If I use the URL

/index.php/ideas

it works just fine.

The directions for the project have a sample nginx configuration file over at GitHub - opencfp/opencfp: Repo for OpenCFP project, a PHP-based conference talk submission system

Thanks in advance for any help with what the rewrite rule should look like

I can’t seem to find the nginx config file in the repo, you may want to link to it.

But I have fixed the obvious error from the config you shared which is with rewrite.

localhost:8080
root /Users/chartjes/Sites/opencfp/web
fastcgi / /Users/chartjes/.valet/valet.sock php
rewrite / {path} {path}/ /index.php/{path}
log access.log
errors error.log

Note: The rewrite syntax was introduced in 0.10.14, I assume you are on the latest version.

Hi abiosoft.

After updating to the latest version of caddy (I was on 0.10.11) your suggested changes work. Thank you so much for the help!

I know this is not the use case for many but it is good to see a fully functional setup with (php) fastcgi, rewrite and logs without any braces and just 6 lines of config.

@abiosoft is the one-line rewrite form still an exact-match from?

The docs still specify it’s exact, in which case the braced form would be needed to catch-all, right? e.g.

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

The one-liner is not exact match anymore, it is now a regex match. Yeah, the doc needs to be updated.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.