Jump to content

HELP! 404 rule on images not working with PHP-CGI


Recommended Posts

Have two dedicated servers. One with PHP-CLI and other with Fast-CGI + PHP-FPM both hosted with Apache 2.

 

Hosted same prestashop on both the servers for testing after changing the prestashop config files

 

Website works perfectly fine on PHP-CLI. There is 404.gif image for products which do not have image

 

 

 

On PHP-CGI, Fast-CGI + PHP-FPM

Everything looks fine except that on 404 status return for an Image url, the url is not redirected to /img/404.gif

 

 

It has something to do with below in 404.php but I am not sure what else is needed on the server to correct it.

 

if (in_array(substr($_SERVER['REQUEST_URI'], -3), array('png', 'jpg', 'gif')))

{

require_once(dirname(__FILE__).'/config/settings.inc.php');

header('Location: '.__PS_BASE_URI__.'img/404.gif');

exit;

}

 

Please help if anyone is aware of a solution.

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

Ok.. Found a temporary fix.. Added 302 found header in above code. Please let me know if there is any other possibility.

 

if (in_array(substr($_SERVER['REQUEST_URI'], -3), array('png', 'jpg', 'gif')))

{

 

require_once(dirname(__FILE__).'/config/settings.inc.php');

header('HTTP/1.1 302 Found');

header('Location: '.__PS_BASE_URI__.'img/404.jpg');

exit;

}

Link to comment
Share on other sites

×
×
  • Create New...