A WordPress plugin that logs 404 errors and provides insights into missing pages, with optional auto-redirect functionality.
- Automatic 404 Logging: Captures all 404 errors including path, referrer, user agent, IP address, and timestamp
- Top Missing Pages: View summary of most frequently accessed missing URLs
- Recent 404 Errors: Browse recent 404 errors with detailed information
- Statistics Dashboard: Quick overview of total errors and unique URLs
- Auto-Redirect Rules: Set up custom redirect rules for commonly missing pages
- AJAX-Powered Management: Delete individual logs or clear all logs without page refresh
- Spam Protection: Prevents duplicate logging within 1-minute intervals
- Secure & WPCS Compliant: Follows WordPress coding standards with proper sanitization and escaping
- Upload the
yt-404-logger-insightsfolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Tools → 404 Logs to view logged errors
- Configure auto-redirect rules at Settings → 404 Logger
Navigate to Tools → 404 Logs in your WordPress admin to see:
- Statistics: Total 404 errors and unique URLs
- Top Missing Pages: Most frequently accessed missing pages with hit counts
- Recent 404 Errors: Latest 404 errors with referrer, IP address, and timestamp
- Delete Single Entry: Click the "Delete" button next to any log entry
- Clear All Logs: Use the "Clear All Logs" button to remove all entries at once
- Go to Settings → 404 Logger
- Enable "Enable Auto-Redirect" checkbox
- Add redirect rules in the format:
/old-url => /new-url - Example:
/old-blog-post => /new-blog-post /products/discontinued-item => /products /contact-us => /contact - Save changes
When enabled, visitors accessing a 404 URL with a matching redirect rule will be automatically redirected (301) to the specified page.
The plugin creates a custom table wp_yt_404_logs with the following structure:
id: Unique log entry IDpath: The 404 URL pathreferer: HTTP referrer (where the visitor came from)user_agent: Browser user agent stringip_address: Visitor's IP addresslogged_at: Timestamp when error occurred
yt-404-logger-insights/
├── class-yt-404-logger-insights.php # Main plugin file (~500 lines)
├── assets/
│ ├── css/
│ │ └── yt-404-logger-admin.css # Admin page styles
│ └── js/
│ └── yt-404-logger-admin.js # Admin AJAX functionality
└── README.md # This file
All functions, classes, and database elements use the yt_404_logger prefix:
- Class:
YT_404_Logger_Insights - Constants:
YT_404_LOGGER_* - Functions:
yt_404_logger_* - Options:
yt_404_logger_options - Database:
wp_yt_404_logs - Text Domain:
yt-404-logger-insights
- Capability checks (
manage_options) - Nonce verification for AJAX requests
- Input sanitization (
sanitize_text_field,sanitize_textarea_field) - Output escaping (
esc_html,esc_url,esc_attr) - Prepared SQL statements (via
$wpdb->prepare()) - IP address validation
- Spam protection (rate limiting)
The plugin uses standard WordPress admin UI components and jQuery for compatibility with all modern browsers.
When the plugin is deleted via WordPress admin:
- All plugin options are removed
- The custom database table is dropped
- WordPress cache is flushed
No data is left behind after uninstallation.
- WordPress 5.8 or higher
- PHP 7.4 or higher
- MySQL 5.6 or higher
- Total Lines: ~500 lines (PHP)
- Single File Architecture: Main plugin in one PHP file
- Additional Assets: 1 CSS file (~100 lines) + 1 JS file (~100 lines)
GPL v2 or later
Krasen Slavov
- Website: https://krasenslavov.com
- GitHub: https://github.com/krasenslavov
For issues and feature requests, please visit the GitHub repository.