Hello,
I’m glad you enjoy the plugin’s redirection matching ??
About the Redirection log: If you want to keep redirection logs but don’t want to show PHP warnings on your site you can set those 3 constants in your wp-config.php
:
define('WP_DEBUG', true); // Activate Debug Mode
define('WP_DEBUG_LOG', true); // Activate Debug Log File
define('WP_DEBUG_DISPLAY', false); // Disable Debug Display on site
With this configuration, you’ll see redirection data in the debug.log
file but you won’t show errors on your site. More informations about debugging in WP: https://www.ads-software.com/support/article/debugging-in-wordpress/
About Wordfence: Wordfence will warn you if the debug.log
file can be accessed publicly. In the scan warning, you can click on the “Fix it” button, this will add a rule in your .htaccess
to disallow public view, which is a good practice.
Why WP 404 Auto Redirect to Similar Post use Debug Log to log redirections:
I want to keep this plugin as much lightweight as possible, that’s why I don’t want to write anything in the Database during the redirection process.
If I add the option “Save redirections logs in database” for people that want to use it, it would mean that the plugin have to check if the option is ON (database call) in every redirection, which would penalize people that don’t want to use this feature.
Alternative solution (for developers):
Thanksfully, there’s many hooks available for developers who want to add custom behavior. Here is a code example that will be run on every redirection:
// Do something after a redirection
add_action('wp404arsp/after_redirect', 'my_404_log_redirect');
function my_404_log_redirect($query){
// Print $query array for more request context
// Add redirection to specific post type 'my-404-log'
$redirection_id = wp_insert_post(array(
'post_type' => 'my-404-log',
'post_title' => 'redirection'
));
// Add all redirection informations in the post_meta 'data'
add_post_meta($redirection_id, 'data', $query);
}
I hope it answered your questions.
Have a nice day ??
Regards.