Skip to content

Instantly share code, notes, and snippets.

@svebal
Created July 12, 2023 10:50
Show Gist options
  • Save svebal/cd6071ecd9bb1a29c241ba7c190509a0 to your computer and use it in GitHub Desktop.
Save svebal/cd6071ecd9bb1a29c241ba7c190509a0 to your computer and use it in GitHub Desktop.
protect wp-debug.log from public access
//Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
//Prevent directory listings
Options All -Indexes
<Files debug.log>
order deny,allow
deny from all
allow from 127.0.0.1
</Files>
<?php
/**
* in wp-config.php
**/
/* Debugging */
define( 'WP_DEBUG', true );
define( 'SCRIPT_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
if ( WP_DEBUG ) {
// turn off wordpress debug logging (otherwise it will be overwritten)
define( 'WP_DEBUG_LOG', false );
// specify new safe path
$path = realpath( $_SERVER["DOCUMENT_ROOT"] ) . '/wp-logs/debug.log';
// enable php error log
@ini_set( 'log_errors', 'On' ); // enable or disable php error logging (use 'On' or 'Off')
@ini_set( 'error_log', $path );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment