0

I used OSTraining's instructions to Create a Custom Joomla 404 Page with 404 Status Code in one of my J! 3.5.1 sites. However, the error_log is flooded with the following errors:

[09-Jun-2016 04:05:45 America/Detroit] PHP Warning:  file_get_contents({...}/404): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

Occasionally, a few other warnings pop up:

[08-Jun-2016 13:15:22 America/Detroit] PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/{...}/public_html/templates/theme1666/error.php on line 26
[08-Jun-2016 13:15:22 America/Detroit] PHP Warning:  file_get_contents({...}http/404): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/{...}/public_html/templates/theme1666/error.php on line 26
[08-Jun-2016 13:15:22 America/Detroit] PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/{...}/public_html/templates/theme1666/error.php on line 26
[08-Jun-2016 13:15:22 America/Detroit] PHP Warning:  file_get_contents({...}http/404): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/{...}/public_html/templates/theme1666/error.php on line 26

Here is my code showing line 26:

if ($this->error->getCode() == '404') : {
  header("HTTP/1.0 404 Not Found");
  echo file_get_contents(JURI::root().'404');
  exit;
}

Obviously, the network errors are due to non-existent URLs. However, the question remains, why is the JURI::root() function randomly generating non-existent URLs? And, why am I getting 500 errors when the page seems to display correctly?


Note: {...} represents account or domain name.

  • Are you sure you're copying the alias of the article? Be sure you assign the article to a menu item too – Lodder Jun 9 '16 at 19:08
  • It isn't producing random URLs. That would produce the URL www.mydomain.com/404, you need to have an endpoint (aka file, menu alias) that appears not to exist. – Brian Bolli Jun 10 '16 at 13:11
  • @Lodder & @BrianBolli, I have ensured that there is, indeed, a published menu item with alias "404" which points to the single article, also having the alias "404". – Michael Yaeger Jun 10 '16 at 15:14
  • I am still getting this error, daily. Any other suggestions? – Michael Yaeger Jun 21 '16 at 21:06
  • Not sure if this will have any impact but you do not need the ":" in the if statement. – BodgeIT Sep 1 '16 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.