But that’s exactly what I need ! And it’s not working, even if I put this rewrite above the other one… May I have to use the if match logic ?
WordPress doesn’t need to be involved, I just want the URL to be rewritten by removing some information in it. It’s purely static and it would be the same if I used Hugo instead of WordPress. And if I moved to a static engine, how could I redirect old URLs to the new one if Caddy does not let me do this simple rewrite ?
I guess I understand why you say that @matt, but I think it’s better if Caddy handles this kind of thing. I would rely on Apache or NGINX, so why not Caddy ?
Indeed. The issue is with old links, inside existing posts (those, I could find and correct myself) but also anywhere on the internet. These old links should be automatically redirected to the new links. Using a 301 redirect, yes.
For years, I displayed dates in my URLs (which is the WordPress default), and then, I switched to simpler permalinks, with only the slug of the post after the domain name. Everything works then inside WordPress (for instance, all archive pages are updated accordingly), but you have to use a rewrite rule on your server to redirect old links.
If rewrite worked then everyone would still use the old style links for older posts. The of rewrite as a proxy to a different path. It would still show to old link in people’s browser.
It’s a great fit for a plugin. Matt doesn’t want Caddy doing too many things in the core. But don’t worry, plugins are super easy to get! I’ll look into how to make one for 0.9. So it may be a little while before I come up with anything since .9 isn’t out yet.
Yes, redir now supports regex using the if match condition. e.g. if {path} match /regex. But it does not support numbered regex captures like rewrite does.