Disable error_log via htaccess

htaccess & Redirects | Updated 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

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 March 2026 · Browse all htaccess articles

  • 136 Users Found This Useful

Was this answer helpful?

Related Articles

Redirecting non-www to www with htaccess

htaccess & Redirects | Updated 2026 Choosing between www and non-www for your domain is a...

When I Upload an htaccess File It Disappears

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

Create a 410 Redirect for Missing Files

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

Show longer file names in directory/folder index

If you've ever wanted to show longer file names in your directory listing just create or edit an...

htaccess referral redirect

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



Save 30% on web hosting - Use coupon code Hosting30