Skip to main content
Notice removed Authoritative reference needed by Kul
Bounty Ended with Mr. Lewis's answer chosen by Kul
Tweeted twitter.com/StackMagento/status/951168838648909824
Notice added Authoritative reference needed by Kul
Bounty Started worth 100 reputation by Kul

I am trying to modify HTTP header for current URL. I want to set 410 status if current page header is 404.

below code iI used but iI have created new controller so it always set 410 for that controller but iI want to set for current urlURL.

$resultPage = $this->resultPageFactory->create();

    $resultPage = $this->resultPageFactory->create();

    $resultPage->setStatusHeader(410, '1.1', 'Gone');
    $resultPage->setHeader('Status', '410 Gone');

    return $resultPage;

I am not sure which function used to set Http header. Has anyone has idea?

I am trying to modify HTTP header for current URL. I want to set 410 status if current page header is 404.

below code i used but i have created new controller so it always set 410 for that controller but i want to set for current url.

$resultPage = $this->resultPageFactory->create();

$resultPage->setStatusHeader(410, '1.1', 'Gone');
$resultPage->setHeader('Status', '410 Gone');

return $resultPage;

I am not sure which function used to set Http header. anyone has idea?

I am trying to modify HTTP header for current URL. I want to set 410 status if current page header is 404.

below code I used but I have created new controller so it always set 410 for that controller but I want to set for current URL.

    $resultPage = $this->resultPageFactory->create();

    $resultPage->setStatusHeader(410, '1.1', 'Gone');
    $resultPage->setHeader('Status', '410 Gone');

    return $resultPage;

I am not sure which function used to set Http header. Has anyone idea?

Source Link
Kul
  • 1.8k
  • 5
  • 29
  • 54

Magento2: How to modifiy http header of page?

I am trying to modify HTTP header for current URL. I want to set 410 status if current page header is 404.

below code i used but i have created new controller so it always set 410 for that controller but i want to set for current url.

$resultPage = $this->resultPageFactory->create();

$resultPage->setStatusHeader(410, '1.1', 'Gone');
$resultPage->setHeader('Status', '410 Gone');

return $resultPage;

I am not sure which function used to set Http header. anyone has idea?