I'm running a job site where content appears and disappears quickly. This means I end up with a lot of 404s from Google indexing pages only for them to disappear.
I want to redirect all unpublished nodes of a certain type to a particular page, depending on a value on the node and display a drupal message depending on what just happened.
I'm trying to come with a solution which is easy to maintain and will scale, should the site grow to have thousands of nodes.
Has anyone solved this sort of problem? What kind of solution did you use?
My current ideas
- Use the redirect module.
I've created a module which will redirect all my nodes when they're unpublished via either a cron action or a form action using the redirect API.
The problem is this creates a lot of redirects. While it might take a while to become unmanageable, several other questions mention the module scales quite well into the thousands I would like it to be future proof is possible.
One option to solve this was to delete unused redirects however because I run Varnish in front as a cache, it is unable to tell which redirects have been active.
- Do it server side
I'm running Nginx, I presumably could set up a location block which would redirect all 404s.
If I put the node information I needed in the URL I could just grab it from there and then redirect each set of nodes.
This is an ok solution, but the pages are redirecting to country so there would have to be 330 location blocks in my nginx config, which isn't particularly slick.
It also makes it impossible to set a message on page load.
- Use the rules module
You can setup content viewed redirects using the rules modules but unfortunately Varnish caching breaks this.