htaccess & Redirects

Disable error_log via htaccess

Updated November 2026 9,979 views 3 min read
htaccess & Redirects | Updated November 2026

The error_log file in your public_html directory captures PHP errors. If it is growing large or you want to disable error logging to a file, you can control this through .htaccess or .user.ini.

01. Disable Error Logging

Create or edit .user.ini in your public_html:

log_errors = Off
Not Recommended

Disabling error logging means you lose visibility into PHP issues on your site. If your site breaks, there is no log to diagnose the problem. A better approach is to redirect the log or manage its size.

02. Redirect the Log (Better Option)

If the issue is that error_log is publicly accessible or growing too large in public_html, move it outside the web root:

error_log = /home/username/logs/php_errors.log

Create the logs directory first: mkdir ~/logs

03. Hide Display Errors (Keep Logging)

If you want to keep logging errors to a file but stop showing them to visitors in the browser:

display_errors = Off
log_errors = On

This is the recommended production setting. Errors are written to the log file for you to review, but visitors see a clean error page instead of PHP stack traces.

04. The error_log File Is Huge

It is safe to delete error_log. A new one is created automatically when the next error occurs:

rm ~/public_html/error_log

If it keeps growing quickly, fix the underlying PHP errors rather than just deleting the file. Check cPanel > Metrics > Errors for the most recent entries.

For more on .htaccess and PHP configuration, see Complete Guide to .htaccess.

Constant PHP Errors?

If your error_log is filling up rapidly, there is likely a code or plugin issue. Open a ticket with a few sample lines from the log.

Open a Support Ticket

Frequently Asked Questions

How do I disable the PHP error_log file?

Add php_flag log_errors off to .htaccess, or set log_errors = Off in a .user.ini or the MultiPHP INI Editor. A better option is to redirect the log to a path outside public_html instead of disabling it, so you keep errors for debugging without the file bloating your web root.

Should I disable error logging entirely?

Usually not. Redirect the log to a file outside public_html with php_value error_log /home/user/php_errors.log so you keep the errors but control where they go. Turn off display_errors on production, but keep logging for troubleshooting.

My error_log file is huge, what do I do?

It means a script is erroring repeatedly. Open the file to find the recurring error and fix the cause rather than just deleting it, since it refills. You can safely delete or truncate it after noting the error; it regenerates.

How do I hide errors from visitors but keep logging?

Set display_errors off so visitors never see errors, while leaving log_errors on with error_log pointing at a file. Visitors get clean pages and you still have the log to debug from.

Quick Recap

  1. Disable logging - log_errors = Off in .user.ini (not recommended)
  2. Redirect the log outside public_html (better option)
  3. Hide from visitors - display_errors = Off with log_errors = On
  4. Safe to delete the error_log file, it recreates automatically
  5. Fix the errors rather than just hiding them

PHP error management · Last updated November 2026 · Browse all htaccess articles

Share: X in Reddit f Email
  • 136 Users Found This Useful

Was this answer helpful?

Related Articles

How to Create a Temporary 302 Redirect via htaccess

htaccess & Redirects | Updated November 2026 A 302 redirect sends visitors (and search...

htaccess referral redirect

htaccess & Redirects | Updated January 2026 You can use .htaccess to redirect visitors...

When I Upload an htaccess File It Disappears

htaccess & Redirects | Updated November 2026 Your .htaccess file is there. You just can't...

Complete Guide to htaccess on Apache

htaccess & Redirects | Updated January 2026 The .htaccess file is one of the most powerful...

Create a 410 Redirect for Missing Files

htaccess & Redirects | Updated November 2026 A 410 (Gone) status code tells search...



Save 30% on web hosting - Use coupon code Hosting30