Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Redirect returns 404

Solved by Hugh Barnes View solution

Started by Sjoerd Smeets 7 years ago · 2 replies · 683 views
7 years ago

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:

TXT
'redirects':
  /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?

7 years ago Solution

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.

7 years ago

Thank you, stripping the trailing slash did it!

Suggested topics

Topic Participants Replies Views Activity
Support · by Anna, 2 days ago
3 120 15 hours ago
Support · by gtx, 1 week ago
4 241 3 days ago
Support · by Paul Hodges, 2 weeks ago
13 285 6 days ago
Support · by Anna, 3 weeks ago
9 344 1 week ago
Support · by TomW, 2 weeks ago
4 195 2 weeks ago