• Resolved steveraven

    (@steveraven)


    Just installed this, set my fallback page to default 404, tried a few ‘search’ terms in my url’s, and lo and behold, you get immediately redirected to the nearest matched page!

    Just like it says!

    I’ve got a problem with the redirection log though, the one where you need to set DEBUG to ‘true’, and DEBUG LOG to ‘true’.

    VERY clunky, and I can see a plugin being updated sometime that’s not coded quite right, and all the debug information being splayed out on the homepage for all to see!

    Is there not a better way to view the redirection logs?

    • This topic was modified 5 years, 1 month ago by steveraven.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter steveraven

    (@steveraven)

    ALSO – just had an email sent over from Wordfence that the DEBUG LOG thing has been cited as an error, and advised removal.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    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.

    Thread Starter steveraven

    (@steveraven)

    Yes, that’s a very comprehensive answer.

    I’ve actually set all three debug constants, using various ‘false’ and ‘true’, and the debug log just looks very messy, with one plugin that’s awaiting an update throwing loads of errors up.

    Alternatively, I’ve been using ‘404 Solution’ plugin, which DOES have logs, but has nowhere near the same consistency that this plugin has, and if only one word in the page title is wrong, you can guarantee it’ll 404 it – requiring that you add a further redirect.

    So after all this research and testing, even without a ‘logs’ section, I reckon that this one is the way to go for supreme laziness ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Genius?’ is closed to new replies.