Jump to content

Force 404 without 302


Recommended Posts

Hello, I've modified the Dispatcher.php class so, when the url is modified and it doens't match the real product url it will redirect you to the 404 page, this is they code I've used to redirect it:

Tools::redirect('index.php?controller=404');

I get redirected to my 404 page, but the problem is that, along with the 404 (red arrow), a 302 from the redirect is send (yellow arrow).

image.thumb.png.03c54fde19a6222d8312c0e11cdec2ec.png

I've also tried using:

Controller::getController('PageNotFoundController')->run();

 

But I receive this screen instead of my 404 website:

 

image.thumb.png.a5e0d9445381f3e86c18186e578259ed.png

Is there a way of forcing the 404 without the 302?

 

Thanks.

Edited by sferrerowebimpacto (see edit history)
Link to comment
Share on other sites

In case anyone has this problem in the future what I ended up doing was putting this code inside de init function of ProductController when it meets my condition:

header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
$this->setTemplate('errors/404');

 

Edited by sferrerowebimpacto (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...