prefix . 'redirects_404'; $offset = ($page - 1) * $per_page; // Base query $where_clause = "WHERE 1=1"; $params = array(); // Add search filter if (!empty($search)) { $where_clause .= " AND url LIKE %s"; $params[] = '%' . $wpdb->esc_like($search) . '%'; } // Validate order by column - WordPress style column names $allowed_columns = ['last_redirected', 'url', 'count']; if (!in_array($order_by, $allowed_columns)) { $order_by = 'last_redirected'; } // Validate order direction $order_dir = strtoupper($order_dir); if (!in_array($order_dir, ['ASC', 'DESC'])) { $order_dir = 'DESC'; } // Get total count for pagination $total_query = "SELECT COUNT(*) FROM {$table_name} {$where_clause}"; if (!empty($params)) { $total_items = $wpdb->get_var($wpdb->prepare($total_query, $params)); } else { $total_items = $wpdb->get_var($total_query); } // Get paginated results $query = "SELECT * FROM {$table_name} {$where_clause} ORDER BY {$order_by} {$order_dir} LIMIT %d OFFSET %d"; $query_params = array_merge($params, [$per_page, $offset]); $results = $wpdb->get_results($wpdb->prepare($query, $query_params), ARRAY_A); return array( 'data' => $results, 'total' => (int)$total_items, 'pages' => ceil($total_items / $per_page), 'current_page' => $page ); } // Function to build WordPress-style column sort URL function get_column_sort_url($column, $current_order_by, $current_order_dir) { $new_order_dir = 'ASC'; // If clicking the same column, toggle direction if ($current_order_by === $column) { $new_order_dir = ($current_order_dir === 'ASC') ? 'DESC' : 'ASC'; } $current_url = remove_query_arg(['orderby', 'order'], $_SERVER['REQUEST_URI']); $sort_url = add_query_arg([ 'orderby' => $column, 'order' => strtolower($new_order_dir), 'paged' => 1 // Reset to first page when sorting ], $current_url); return $sort_url; } $options = P404REDIRECT_get_my_options(); function p404_cleanup_image_options() { $options = P404REDIRECT_get_my_options(); $image_id = isset($options['image_id_p404_redirect_to']) ? absint($options['image_id_p404_redirect_to']) : ''; if ($image_id != '') { $image_data = wp_get_attachment_image_src($image_id); if (!$image_data || empty($image_data[0])) { // Image doesn't exist, clear the option $options['image_id_p404_redirect_to'] = ''; update_option('p404_redirect_options', $options); return false; } } return true; } ?> '; echo '

Cache Plugin Detected: You have a cache plugin installed (' . P404REDIRECT_there_is_cache() . '). Please clear your cache after making changes for them to take effect immediately.

'; echo ''; } // Get the current email options (add defaults if they don't exist) $email_enabled = P404REDIRECT_read_option_value('email_notifications_enabled', '1'); // Default: enabled $email_frequency = P404REDIRECT_read_option_value('email_frequency', 'weekly'); // Default: Weekly $notification_email = P404REDIRECT_read_option_value('notification_email', get_option('admin_email')); // Default: Admin email ?>

All 404 Redirect to Homepage

Manage your 404 error redirections and broken image handling with professional-grade controls

404 Pages Settings

add('Enabled', '1'); $drop->add('Disabled', '2'); $drop->dropdown_print(); $drop->select($options['p404_status']); ?>
Enable or disable 404 page redirections to improve user experience
Enter the destination URL where visitors should be redirected when they encounter 404 errors
add('301 Permanent Redirect', '301'); $drop->add('302 Temporary Redirect', '302'); $drop->dropdown_print(); $redirect_type = isset($options['p404_redirect_type']) ? $options['p404_redirect_type'] : '301'; $drop->select($redirect_type); ?>
301 redirects are recommended for SEO as they transfer link equity to the destination page
add('Yes', '1'); $drop->add('No', '2'); $drop->dropdown_print(); $p404_execlude_media_val = isset($options['p404_execlude_media']) ? $options['p404_execlude_media'] : '1'; $drop->select($p404_execlude_media_val); ?>
Exclude media files (images, videos, etc.) from 404 logging to keep your database clean and efficient

404 Images Settings

add('Enabled', '1'); $drop->add('Disabled', '2'); $drop->dropdown_print(); $image_status_val = isset($options['img_p404_status']) ? $options['img_p404_status'] : '2'; $drop->select($image_status_val); ?>
Enable to show a default image for broken images instead of broken image icons. For advanced features, try our Broken Images Redirection Plugin
This image will be displayed whenever a requested image is not found on your website

Email Notifications Settings

add('Enabled', '1'); $drop->add('Disabled', '2'); $drop->dropdown_print(); $drop->select($email_enabled); ?>
Enable to receive email summaries of 404 activity on your website
add('Daily', 'daily'); $drop->add('Weekly', 'weekly'); $drop->add('Monthly', 'monthly'); $drop->dropdown_print(); $drop->select($email_frequency); ?>
How often you want to receive email summaries (weekly is recommended)
= 5): ?>
Email address where 404 summaries will be sent (defaults to admin email)
⚠️ Test email available after recording 5+ redirects (currently: )
= 5): ?>
Click "Send Test Email" to preview how your 404 analytics report will look
  • 📊 Total 404 errors count
  • 🔗 Most frequent broken URLs
  • 📈 Trend compared to previous period
  • 🌐 Top referrers causing 404s
  • 💡 Recommendations to fix issues
prefix . 'redirects_404'; $total_redirects = P404REDIRECT_read_option_value('links', 0); // Get unique IPs count (last 30 days) $unique_ips = $wpdb->get_var($wpdb->prepare(" SELECT COUNT(DISTINCT ip_address) FROM {$table_name} WHERE last_redirected >= %s AND ip_address IS NOT NULL AND ip_address != 'unknown' ", date('Y-m-d H:i:s', strtotime('-30 days')))); // Get unique URLs count (last 30 days) $unique_urls = $wpdb->get_var($wpdb->prepare(" SELECT COUNT(DISTINCT url) FROM {$table_name} WHERE last_redirected >= %s ", date('Y-m-d H:i:s', strtotime('-30 days')))); ?>
Total Redirects Handled
All time
Unique Broken URLs
Last 30 days
Unique Visitors
Last 30 days

Plugin installed on:

Clear
$redirect) { ?>
# Last Redirected URL Redirect Count

No Results Found

No URLs match your search for ""

Clear search to see all results.

No 404 Redirects Yet

When visitors encounter 404 errors, they'll appear here.

1) { ?>
Showing to of entries (filtered from total)
1) { ?> $i"; } ?>

Confirm Data Deletion

You are about to permanently delete all 404 redirect logs from the database.

This action cannot be undone and will remove:

  • All recorded 404 URLs
  • Redirect counts and timestamps
  • Historical tracking data

Are you sure you want to proceed?

Boost your SEO and fix 404 errors! 🚀

Use SEO Redirection Pro to manage redirects, eliminate broken links, and improve your search engine rankings. Get better results today!

SEO Redirection Pro

Manual .htaccess Configuration Required

Warning: Your .htaccess file is not writable by WordPress. You need to add the following code manually.

Please copy and paste the following code into the first line of your .htaccess file:

RewriteOptions inherit
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.(gif|jpe?g|png|bmp) [NC,L]
</IfModule>

Note: Make sure to backup your .htaccess file before making any changes.

Unable to Save Settings

Settings Saved Successfully

Image Upload Required