How to change the way of handling 404 errors
-
We use nginx and the setup for converting JPEGs/PNGs to WEBP on the fly using your plugin works perfectly. But it now seems impossible to create a custom redirect for a special case of missing image files.
As far as it’s on the way of handling 404 errors for the images in the uploads folder, we can’t change the way these errors have been handled. For now, if your webp-on-demand.php can’t find an image to convert, it throws the error message:
"Sanity check failed for source (passed as absolute path on nginx): File does not exist or is outside restricted basedir"I’ve recently removed a dozen of mostly unused image sizes and deleted the images corresponding to them which matches ^(/.+)-\d+x\d+(\.jpe?g|png). Now I need a redirect to the full-size version of the image (i.e. $1$2 if the request URL matches the mentioned pattern) if the missing resized version is requested. In all other cases, it’s better to show the server’s standard Error 404 page instead of the “Sanity check” message.
Can I somehow externally hook up to your function which throws the “Sanity…” message in order to take over the processing of the request? (I probably can modify your plugin’s code, but it isn’t a good idea because my changes would disappear with any update of the plugin).
Another possible solution could be adding the 404 handling settings in the settings of the plugin.
Thank you.
The topic ‘How to change the way of handling 404 errors’ is closed to new replies.