Error Log showing error when frontend displays 404 not found.

8 posts by 4 authors in: Forums > CMS Builder
Last Post: June 10, 2015   (RSS)

By gregThomas - May 11, 2015

Hi Andy,

Would it be possible to post the code for listingDetail.php page? Then I can take a look into what might be causing the issue. 

You can e-mail me the code via support@interactivetools.com if you'd prefer.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By In-House-Logic - May 14, 2015 - edited: May 14, 2015

I can verify this behaviour on one of our new sites also. Pages which fail to find a record in the initial query are redirected to a 404 page. Error logs still fire off though so I'm getting several each day from site sniffers.

Came on today to try to find some info about this. :)  Was going to ask if it was possible to get the error log to record the referring URL string as well as the page failure. I am thinking that users are arriving from mal-formed links on other pages but I have no way of knowing what page was sending them to the one throwing the error. I think this would still be useful and I'd love to know how to add this if possible.

Discovered that the error log in CMSB itself does capture the whole server request array. Found what I needed there.

J.

By andybarn - May 14, 2015

Hi Greg

Please find the file attached.

Kind regards

Andy

Attachments:

listingDetail.php 16K

By Damon - May 14, 2015

Hi Andy,

Thanks for sending in the template.

To prevent the errors from appearring in the Error Log when records are not found, change this code:

if (!$listingsRecord) { header('Location: http://www.comparedirect.eu/404-compare-direct.php'); } // redirect to 404 page

to this code:

if (!@$listingsRecord) { header('Location: http://www.comparedirect.eu/404-compare-direct.php'); die; } // redirect to 404 page

I added the @ to the array (that doesn't exist) to suppress that error and the die statement after the redirect so no more code will be run (which generated an error).

Try this out and let me know if you have any questions.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Thanks Damon. Will also give this tweak a try.

Jayme

By andybarn - May 15, 2015

Thanks Damon

I put the code in and tested with an invalid URL and the 404 page came up AND there was no error in the error log file in Admin.

All good - thanks for your excellent support!

Kind regards

Andy

By In-House-Logic - June 10, 2015 - edited: June 10, 2015

Can also confirm that this solves the issue.

It seems like it helps to know what you're doing.

Thanks Damon!