Allow more redirect status codes

Created on 19 March 2014, about 11 years ago
Updated 4 March 2023, about 2 years ago

Hi,

when users delete their nodes it can happen that many times visitors will see the 404-page before the deleted content link disappears from all the internet and the project. Therefore I would like to create a redirect for deleted nodes to a specific node explaining that the content was deleted.

This is not that big thing: with hook_node_delete it is possible to create a redirect managed by this module. In terms of SEO I would like to give the status code 410 (deleted) or at least 404 (not found). But this codes lead to a WSOD. I found out that in line 1033 of redirect.module the status code is defined by a function "redirect_status_code_options", which can be found in line 1380:

function redirect_status_code_options($code = NULL) {
  $codes = array(
    300 => t('300 Multiple Choices'),
    301 => t('301 Moved Permanently'),
    302 => t('302 Found'),
    303 => t('303 See Other'),
    304 => t('304 Not Modified'),
    305 => t('305 Use Proxy'),
    307 => t('307 Temporary Redirect'),
  );
  return isset($codes[$code]) ? $codes[$code] : $codes;
}

I tried to change this function to

function redirect_status_code_options($code = NULL) {
  $codes = array(
    300 => t('300 Multiple Choices'),
    301 => t('301 Moved Permanently'),
    302 => t('302 Found'),
    303 => t('303 See Other'),
    304 => t('304 Not Modified'),
    305 => t('305 Use Proxy'),
    307 => t('307 Temporary Redirect'),
    410 => t('410 Deleted'),
  );
  return isset($codes[$code]) ? $codes[$code] : $codes;
}

but when the old path is called I just see a WSOD (the redirect has the code 410 in database table) - and I do not know why... no error messages appear. Is there a possibility to implement the use of 410 as a status code?

Best,
Tobias

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany tobiberlin Berlin, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024