Redirect returns 404

Hello, i’m currently converting a wordpress website to grav. One of the remaining things to do is the configuration of redirects. That way old url’s still work after Grav takes over.

In my site.yaml i placed this piece of code:

  /2018/04/website-online/:  '/nieuws/20180413-website-online[302]'

When i navigate to domain/2018/04/website-online it gives me a 404 error.
What am i doing wrong?

This looks like it’s as described in the docs.

The only problem may be related to your trailing slash. Be aware there is also a setting redirect_trailing_slash which could be kicking in first, stripping the trailing slash so that your redirect rule never matches. OR if you are only navigating to domain/2018/04/website-online as you say, that won’t match as there is no slash.

Some things that will help you diagnose:

  • is your browser redirecting to /nieuws/20180413-website-online and you see the 404 from that address? Or are you seeing the 404 from the original URL? That should tell you if the rewrite rule is matching.
  • your server log file should contain a line for every request and the response provided. So you should see the URL you put in, a response of 302, and then another request on the next line to where it is taking you. And you should see at which stage it’s serving the 404.

Hope that helps.

Thank you, stripping the trailing slash did it!