getgrav / grav-plugin-error

Grav Errors Plugin
https://getgrav.org
MIT License
4 stars 29 forks source link

Feature request: forward 404 to server #21

Open Swader opened 8 years ago

Swader commented 8 years ago

I know the plugin is "required", but I'd like to be able to customize the 404 reaction - in a nutshell, I would like it to be able to let the server handle the 404, so that the server can redirect a nonexistent post to my old blog, which is on a different subdomain now. Can this be done easily?

flaviocopes commented 8 years ago

You can set redirects so instead of having a 404 you get a 301 redirect to the subdomain, see https://learn.getgrav.org/basics/grav-configuration#site-configuration


redirects:
  '/testing': 'https://oldsite.com/testing'
Swader commented 8 years ago

Yeah, but I have hundreds of posts on the old system, and I don't have a list of their routes to manually define like that. I would also still need a 404 for actually non-existing posts, those that don't have an old counterpart.

mahagr commented 8 years ago

Once server has given the request to PHP, there's no way from PHP to let the server to handle 404 anymore. You could maybe be able to make some proxy setup to do it, but it may be easier to create your own 404 plugin for Grav, which does what you want.