Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi! Would be possible to add a setting to configure this module to return a 410 error instead of a 404?
Currently I'm using a custom version of the module, this is a simple patch for 7.x-1.3 but there are many ways to implement this feature.
Implement 410 errors
.--- fast_404.inc 2012-07-20 23:39:49.000000000 +0200
+++ fast_404.inc.new 2012-07-20 23:39:41.000000000 +0200
@@ -70,7 +70,7 @@
// Determine if URL is in blacklisted extensions.
if ($exts && preg_match($exts, $_SERVER[$server_var], $m)) {
- fast_404_error_return();
+ fast_404_error_return(FALSE, variable_get('fast_404_return_gone', FALSE));
}
define('FAST_404_EXT_CHECKED', TRUE);
@@ -95,7 +95,7 @@
}
if (!$valid) {
- fast_404_error_return(TRUE);
+ fast_404_error_return(TRUE, variable_get('fast_404_return_gone', FALSE));
}
define('FAST_404_PATH_CHECKED', TRUE);
@@ -219,8 +219,14 @@
/**
* Output our super plain error and exit
*/
-function fast_404_error_return($load_html = FALSE) {
- header('HTTP/1.0 404 Not Found');
+function fast_404_error_return($load_html = FALSE, $return_gone = FALSE) {
+
+ if ($return_gone){
+ header('HTTP/1.0 410 Gone');
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ }
+
// If a file is set to provide us with fast_404 joy, load it
if (($load_html || variable_get('fast_404_HTML_error_all_paths', FALSE))
New setting
Add this variable to settings.php to enable "410 Gone" errors instead of "404 Not Found"
$conf['fast_404_return_gone'] = TRUE;
HTML output
Moreover the page HTML should be modified in order to display the new error message.
Thanks for the attention and thanks for implementing this module!
Comments
Comment #1
soyarma CreditAttribution: soyarma commentedI like this quite a bit, it is added.