smart_404
Smart 404 closes the gap between "there are 404 errors on my site" and "I've fixed them." It automatically logs every 404 response, aggregates hits per path, and presents them in a clean admin overview where site builders can create redirects with a single click, directly from the Drupal backend, without touching server logs, analytics dashboards, or the command line.
The module integrates with the standard Redirect module for redirect creation and installs it automatically as a hard dependency, so you get a complete solution out of the box.
Features
- Automatic 404 logging. Every 404 response is captured via a Symfony event subscriber. Hits are aggregated per normalized path: no duplicate rows, no table bloat.
- Path normalization. Paths are lowercased, trailing slashes stripped, and query strings removed before storage, so
/Over-Ons/and/over-onscount as one entry. - Admin overview. Filterable, paginated table showing path, hit count, first seen, last seen, referer source, and bot indicator. Bulk actions: create redirects, ignore, or delete.
- One-click redirect creation. Form pre-filled with the source path and the best matching existing alias as a destination suggestion.
- Intelligent path suggestions. The suggestion engine queries the path alias table using a fragment match and ranks candidates by Levenshtein distance. Results are cached per path for one hour.
- Bulk redirect form. Select multiple 404 paths and create all redirects on one confirmation page, with per-row destination editing.
- Bot detection. User agents are categorized as bot, browser, or unknown. Only the category is stored, never the raw UA string. Bot traffic can be hidden from the overview or excluded from logging entirely.
- Ignore patterns. Glob patterns (e.g.
/wp-admin/*,*.php) exclude known false-positives from ever being logged. Sensible defaults are included. - Configurable retention. Automatic cleanup via cron: delete records older than N days and enforce a maximum record count. Zero configuration required to get started.
- GDPR-aware by design. No IP addresses stored, no external services, no tracking. External referers are stored as domain-only. Raw user-agent strings are discarded immediately after categorization.
- Status tracking. Each path has a status: New, Ignored, or Resolved. Resolved paths show the linked redirect entity ID.
- Permission-based access. Three granular permissions for viewing, redirect creation, and settings management.
Use cases
- A content editor renames a page: the old path quickly appears in the 404 overview and can be redirected in seconds.
- A site migration leaves dozens of broken internal links: bulk-create redirects from one screen without opening a spreadsheet.
- External sites link to outdated URLs: referer information shows exactly where the broken links come from so you can notify the source.
- A developer wants to monitor 404 trends without granting server access to non-technical staff.
Why not just use the Redirect module?
The Redirect module solves the problem once you already know about it. Smart 404 helps you discover the problem in the first place. Without a logging layer, you need to download server logs, run grep commands, or pay for analytics tools to find out which paths are returning 404s. Smart 404 eliminates that gap: log in to the Drupal backend, open the 404 overview, and start fixing. No technical knowledge required.
Requirements
- Drupal 10.3 or higher, or Drupal 11
- PHP 8.1 or higher
- Redirect module ≥ 1.9 (installed automatically as a Composer dependency)
Installation
Install via Composer. The Redirect module is pulled in automatically:
composer require drupal/smart_404 drush en smart_404 -y drush cr
Or enable via the UI at Manage > Extend > Smart 404. Drupal will offer to install the Redirect module at the same time if it is not yet active. No manual database setup is required.
Configuration
After installation, visit Manage > Configuration > System > Smart 404 to adjust:
- Retention period. How many days to keep records (default: 90 days, based on last-hit date).
- Maximum records. Cap on total stored paths (default: 10,000). Oldest records are removed first when the cap is exceeded.
- Strip query string. Normalize
/search?q=aand/search?q=bto the same path entry (default: enabled). - Log bot traffic. Disable to exclude known crawlers and scanners from the log entirely (default: enabled; bots are hidden in the overview by default).
- Log referers. Disable to store no referer information at all (default: enabled).
- Ignore administrators. Skip logging 404s triggered by users with the administer site configuration permission (default: enabled).
The Ignore patterns tab manages a list of glob patterns for paths that should never be logged. The 404 log overview is available at Manage > Reports > 404 Log.
Frequently asked questions
Does Smart 404 store IP addresses or personal data?
No. IP addresses are never stored at any point. User-agent strings are categorized into three labels (bot / browser / unknown) and only the label is stored. The raw string is discarded immediately. External referers are stored as domain-only (e.g. https://example.com), not as full URLs. The module has no connection to any external service. It is designed to be GDPR-compliant out of the box, though you should always verify compliance for your specific legal context.
Will logging 404s slow down my site?
The performance impact is minimal. Each unique 404 path triggers a single database UPSERT. Repeated hits on the same path within the same request are deduplicated in memory. If the configured record cap has been reached, logging is skipped entirely (checked via a short-lived cache). The event subscriber runs at priority -100, after all other response processing is complete.
My site gets thousands of bot 404s. Will this fill up my database?
Smart 404 has three safeguards: (1) enable "Do not log bot traffic" to discard all recognized bot hits before they reach the database; (2) add glob patterns like /wp-admin/* or *.php to the ignore list, useful defaults are already included; (3) the configurable maximum record count prevents unbounded table growth regardless of traffic volume. Bot hits that are logged are hidden in the overview by default.
Does Smart 404 work on multilingual sites?
Yes. Paths with language prefixes (e.g. /nl/over-ons, /en/about-us) are logged and normalized as separate entries. Language context is detected when creating redirects and passed to the Redirect entity, so redirects apply correctly per language.
What happens when I uninstall Smart 404?
The smart_404_log table and all module configuration are deleted. Redirects that were created via Smart 404 are not deleted. They belong to the Redirect module and remain active. If you also want to remove those redirects, do so manually via Manage > Configuration > Search and metadata > URL redirects before uninstalling.
Does Smart 404 work with multi-domain setups?
Partially. The module logs paths only, so the same path /about on two different domains is counted as one log entry. This is sufficient for single-domain sites. True multi-domain support with per-host log segmentation is planned for version 1.1.
How does the module prevent redirect loops?
Before saving a redirect: source equals destination triggers a hard error. An existing redirect for the source path and a redirect chain on the destination path both trigger a warning. The administrator can override warnings but not hard errors.
Can I export or import the 404 log?
Not in version 1.0. The log is stored in a custom database table, not as Drupal config. A CSV export feature and Views integration (which enables custom exports) are planned for version 1.2.
Roadmap
Version 1.0 (current)
- Automatic 404 logging with path normalization and bot detection
- Admin overview with filters, pagination, and bulk actions
- One-click and bulk redirect creation via the Redirect module
- Intelligent path suggestions (alias fragment match and Levenshtein ranking)
- Ignore patterns for known false-positives
- Configurable retention via cron
- GDPR-aware: no IP storage, categorized user agents, domain-only external referers
Version 1.1 (planned)
- Multi-domain awareness: log and display the host header alongside the path
- Per-day hit timeline on the detail page
- Weekly email digest: summary of new 404s since the last report
- Drush commands:
smart404:report,smart404:cleanup
Version 1.2 (planned)
- Views integration: use the log table as a Views data source for custom reports and exports
- CSV export from the overview table
- Admin dashboard block: top-5 newest 404s in the main admin panel