Home / Admin / Skip Unwanted 404 Logs
Duplicate Snippet

Embed Snippet on Your Site

Skip Unwanted 404 Logs

This snippet will successfully prevent AIOSEO from logging 404 errors for the specified URLs.

<10
Code Preview
php
<?php
add_filter( 'aioseo_redirects_log_skip', 'redirects_log_skip', 10, 2 );
function redirects_log_skip( $skip, $data ) {
    // Define a list of unwanted URLs
    $ignoreUrls = [
        '/config.json',
        '/home',
        '/main',
        '/server-status',
        '/private'
    ];
    // Skip logging these URLs if they result in a 404 error
    if ( 404 === $data['http_code'] && in_array( $data['url'], $ignoreUrls, true ) ) {
        $skip = true;
    }
    return $skip;
}

Comments

Add a Comment