How do I hide folder structure in php generated errors?

Avatar
  • updated
  • Answered
php generates unfriendly and unsecure messages, such as "in /home//public_html/ABC.com/display.php on line 2"
How do I change this so that it does not disclose private directory structure (for security) INCLUDING LOG IN NAME INMOTIONHOSTING!!! and does make a message meaningful to a user "in www/ABC.com/display.php on line 2

======
Post Script

If I seem incredibly anal about this, my last web host, to remain nameless but rhymes with websitesource.net, advertises
viurus/malware checking but does not in fact have it. Malware sat on my web sites undetected for almost a year, which spread to all my web sites in the same directory structure. Cost me man-years of lost work and almost bankrupted me. Advertised backups were also not there.

So to the best of my knowledge, inmotionhosting is light years ahead of that, having both malware scanning and actual backups. So If I sound as if I'm busting chops its from been burned already, and keeping my directory structure and login information private is really important to me for good reason.
Avatar
Tim S.
  • Answered

Hi mrbi11,

Thanks for posting your question. I'm more than happy to assist you today. The error message is being displayed on the screen due to your default settings in your php.ini file. You can turn this off, if you'd like in the php.ini file. Doing so, will not longer display an error message for any visitors but a blank white screen in the browser.

Typically, we recommend turning off display_errors in the php.ini file once your website is released and ready for the public to view. If you are still in the building process, it's best to leave it on or set a path to have the errors stored in a log file.

Here's an article on setting up an error_log file:

Creating a PHP error log file

If you want to turn off PHP debugging so errors will not display on the screen you can do so by editing the line of code in the php.ini file:

display_errors = On

And change it to:

display_errors = Off

I hope this helps! If you need further assistance please feel free to contact us.

Thanks!

Tim S