Please help rewrite nginx config to Caddyfile

There are such lines in my nginx configuration file:

  if (!-e $request_filename)
   {
      rewrite ^/index/([0-9]+)?/$ /index.php?go=/$1 last;
      rewrite ^/post/(.+)?/$ /read.php?go=/$1 last;
      rewrite ^/category/(.+)?/$ /category.php?go=/$1 last;
      rewrite ^/category/(.+)/([0-9]+)?/$ /category.php?go=/$1/$2 last;
      rewrite ^/tag/(.+)?/$ /tag.php?go=/$1 last;
      rewrite ^/tag/(.+)/([0-9]+)?/$ /tag.php?go=/$1/$2 last;
      rewrite ^/send.php/(.+)$ /send.php?go=/$1 last;
      rewrite ^/admin.php/(.+)$ /admin.php?go=/$1 last;
      rewrite ^/page/(.+)?/$ /page.php?go=/$1 last;
 }

It’s a matter of procedure.

Hi @lun, welcome to the Caddy community!

You’re looking for the rewrite directive to approximate this behaviour in Caddy.

The important thing to note when converting it is that where Apache and nginx use $1, $2, etc., Caddy uses {1}, {2}, etc. instead.

They’re strikingly similar, though. Give it a shot, tell us how it goes, and if you run into problems, post your attempt and we can have a look.

https://caddyserver.com/docs/rewrite

It looks like a good translation to me.

What’s not working?