Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 314003

Change Header Status Response to 410

$
0
0

Hi,

I have several urls with "/tag/" string; some of them have content and some of them don't so they return 404.

How can I force them to return a 410 only for those that have no content?

I need a filter: has "/tag/" in URL and returns 404 -> redirect to 410.

I tried in theme_preprocess_html(&$variables) like this:

if ($pattern2){ //it has "/tag/" string
      $status = \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception');      
      if ($status && $status->getStatusCode() == 404){
          $response = new Response();
          $response->setStatusCode(410);
          return $response;
      }
}

It filters ok but nothing happens. Still 404

Thank you for your help!!


Viewing all articles
Browse latest Browse all 314003

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>