Skip to content

How to Fix 404 Errors Issues on Your Drupal

How to Fix 404 Errors Issues on Your Drupal

How to Fix 404 Errors Issues on Your Drupal

How to Fix 404 Errors Issues on Your Drupal

Overview

How to Fix 404 Errors Issues on Your Drupal

How to Fix 404 Errors Issues on Your Drupal

404 errors occur when a user or search engine tries to access a URL on your Drupal site that does not exist. These errors negatively impact user experience by leading visitors to dead-end pages and can harm your SEO rankings by signaling poor site maintenance and broken link structures. Fixing 404 errors promptly helps retain link equity, improve crawl efficiency, and reduce bounce rates.

Explanation and Impact

A 404 error means the requested page is missing or has been moved without proper redirection. This frustrates users and search engines alike, causing loss of traffic and ranking drops. Properly managing 404 errors with redirects ensures visitors and bots are sent to relevant content, preserving your site’s authority and usability.

Platform-Specific Steps to Identify and Fix 404 Errors on Drupal

  1. Enable the Redirect Module: Install and enable the popular Drupal Redirect module (via Composer or Drupal admin) which provides an interface to manage URL redirects.
  2. Activate Redirect 404 Submodule: This submodule tracks all 404 errors on your Drupal site and lists non-existent URL paths.
  3. Access the "Fix 404 Pages" Tab: Review the list of URLs causing 404 errors, including statistics on how often each is requested.
  4. Create Redirects: For each 404 URL, use the interface to add a redirect to a relevant existing page or the homepage.
  5. Choose HTTP Status Codes: Use 301 redirects for permanent moves and 302 for temporary redirects (e.g., during maintenance).
  6. Monitor Regularly: Continuously monitor 404 errors and fix new ones promptly to maintain site health.

Actionable Solutions and Tools

  • Use the Redirect module’s UI under Configuration > Search and metadata > URL redirects for easy management.
  • Automatically create redirects when URL aliases change to avoid broken links.
  • Enforce clean and canonical URLs to prevent duplicate content and URL variations.
  • Consider domain-level redirects if migrating or rebranding.

Best Practices to Prevent Recurrence

  • Conduct regular content audits to identify removed or merged pages needing redirects.
  • Use the Pathauto module to generate SEO-friendly URLs and avoid typos.
  • Implement canonical tags to signal preferred URLs to search engines.
  • Optimize site speed and mobile responsiveness to improve overall SEO.
  • Maintain an updated XML sitemap and robots.txt file for better indexing.

Summary Checklist

  • [ ] Install and enable the Redirect module and its submodules.
  • [ ] Regularly review the "Fix 404 Pages" tab for new errors.
  • [ ] Create appropriate 301 or 302 redirects for all 404 URLs.
  • [ ] Automate redirects on URL alias changes.
  • [ ] Use SEO-friendly URL structures with Pathauto.
  • [ ] Implement canonical tags to avoid duplicate content.
  • [ ] Monitor site performance and mobile usability.
  • [ ] Keep XML sitemap and robots.txt files up to date.

By following these steps and best practices, Drupal site owners can effectively fix 404 errors, improve user experience, and boost their SEO rankings long-term.

What Is the “404 Errors” Issue?

  • SEO Error Type: 404 Errors
  • Relevant Platform: Drupal

Impact on SEO and User Experience

404 errors, also known as "Page Not Found" errors, negatively impact SEO and user experience by causing poor user experience due to frustration and higher bounce rates. They lead to crawling and indexing issues as search engine bots may reduce crawl efficiency and index fewer pages when encountering many 404s. Additionally, 404 errors cause loss of link equity from expired links, which can lower the ranking potential of other pages on the site. Furthermore, they waste the crawl budget, meaning search engines spend resources on non-existent pages rather than discovering new or updated content. Specifically for Drupal, improper handling of 404 errors (such as returning soft 404s or redirecting to the homepage instead of a proper 404 status) can mislead search engines into thinking non-existent pages are valid, causing indexing of irrelevant URLs and negatively affecting site crawl coverage and rankings.

Common Causes on Drupal

The most frequent causes of 404 errors on Drupal websites include missing or misconfigured .htaccess files, which are essential for URL rewriting and routing. If the .htaccess file is absent or corrupted, Drupal cannot properly handle URLs, leading to 404 errors. Another common cause is the Apache mod_rewrite module being disabled; this module must be enabled to allow Drupal’s clean URLs to function correctly. Incorrect settings in the .htaccess file, especially the RewriteBase directive, can also cause URLs to break and return 404 errors. Additionally, if clean URLs are not enabled or configured properly in Drupal’s admin settings, users may encounter 404 errors when accessing pages. Sometimes, the .htaccess file is not copied during installation because hidden files are not shown or selected, resulting in missing critical configuration. Lastly, an incorrect or missing base_url setting in Drupal’s settings.php file can cause URL resolution issues that manifest as 404 errors. Addressing these issues typically resolves most 404 errors on Drupal sites.

How to Identify “404 Errors” Issues

  1. Log into your Drupal admin dashboard.
  2. Navigate to the "Reports" section.
  3. Click on "Top ‘page not found’ errors" to view a list of URLs causing 404 errors and the frequency of each error.

This built-in report helps you identify and verify 404 errors on your Drupal site efficiently.

How to Fix “404 Errors” on Drupal

To fix 404 errors on your Drupal website, follow these platform-specific actionable solutions:

  1. Ensure .htaccess file is present and correct:
    • Drupal relies on the .htaccess file in the root directory to handle URL rewriting.
    • Check if the .htaccess file exists; if missing, copy it from a fresh Drupal installation archive.
    • If the file is present but issues persist, replace it with a fresh copy to avoid corruption.
    • On some hosting control panels (e.g., cPanel), hidden files like .htaccess may not be copied by default; enable "Show Hidden Files" to verify and copy it.
  2. Enable Apache mod_rewrite module:
    • Drupal requires mod_rewrite for clean URLs.
    • Verify mod_rewrite is enabled in your Apache configuration (httpd.conf).
  3. Configure RewriteBase correctly in .htaccess:
    • If Drupal is installed in a subdirectory, set the RewriteBase directive appropriately (e.g., RewriteBase /subdirectory).
    • If in the root, ensure RewriteBase / is uncommented.
  4. Check Clean URLs setting:
    • Access Drupal admin via URLs with query parameters (e.g., yoursite.com/?q=admin/config/search/clean-urls).
    • Enable or disable Clean URLs as needed to test if this resolves the 404 errors.
  5. Add URL rewrite rules if missing:
    • Add the following to your Apache config or .htaccess if not present:
      <Directory /path/to/drupal>   RewriteEngine on   RewriteBase /   RewriteCond %{REQUEST_FILENAME} !-f   RewriteCond %{REQUEST_FILENAME} !-d   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </Directory> 
  6. Use Redirect 404 Module for managing 404 errors:
    • Enable the Redirect 404 submodule (part of the Redirect module).
    • Navigate to Configuration > URL redirects > Fix 404 pages tab.
    • View logged 404 errors, create redirects or ignore specific errors.
    • This helps improve user experience by reducing broken links.
  7. Clear Drupal caches:
    • After making changes, clear all caches to ensure settings take effect.
  8. Check server logs and troubleshoot:
    • Review Apache and PHP error logs for clues.
    • Ensure there are no permission issues preventing .htaccess from being read.

Best Practices to Prevent Recurrence:

  • Always include the .htaccess file when migrating or deploying Drupal sites.
  • Confirm mod_rewrite is enabled on your server before installation.
  • Regularly monitor 404 logs using modules like Redirect 404.
  • Test URL rewrites and Clean URLs setting after updates or migrations.

Summary Checklist:

  • [ ] .htaccess file present and correct
  • [ ] Apache mod_rewrite enabled
  • [ ] RewriteBase configured properly
  • [ ] Clean URLs setting verified
  • [ ] URL rewrite rules in place
  • [ ] Redirect 404 module enabled and configured
  • [ ] Drupal caches cleared
  • [ ] Server logs checked for errors

These steps address common causes of 404 errors on Drupal sites and provide both immediate fixes and tools for ongoing maintenance to keep your site SEO-friendly and user-friendly.

(Sources: Drupal.org forum and documentation, Drupal Stack Exchange, Drupal Redirect 404 module guide, Drupal groups community posts)

Screenshots and Tool Recommendations

  • Screenshot description: Example of enabling ‘Show Hidden Files’ in cPanel File Manager to ensure .htaccess is copied to Drupal root directory, preventing 404 errors caused by missing .htaccess file.
  • Recommended tool: Use the Drupal admin dashboard Reports > Top ‘page not found’ errors to identify URLs causing 404 errors on your Drupal site.
  • Recommended module: Redirect 404 module (https://www.drupal.org/project/redirect_404) – allows redirecting 404 errors to legacy servers or custom pages, useful during site migrations or to handle broken links gracefully.
  • Best practice: Ensure Apache’s mod_rewrite is enabled and the Drupal .htaccess file is present in the root directory to enable clean URLs and prevent 404 errors.
  • Maintenance tip: Regularly check the Drupal Reports for 404 errors and use the Redirect module to create permanent redirects (301) to valid pages to improve SEO and user experience.

Best Practices for Prevention

To prevent 404 errors on your Drupal website, follow these platform-specific best practices:

  1. Use the Pathauto module to automatically generate SEO-friendly URL aliases for your content, avoiding URLs like "/node/231" and instead using logical, human-readable paths.
  2. Install and configure the Redirect module to automatically create 301 redirects when content paths change, and manually fix crawl errors by redirecting broken URLs to relevant pages.
  3. Utilize the Search 404 module to redirect visitors landing on non-existent pages to a relevant internal search page, reducing bounce rates and improving user experience.
  4. Regularly monitor crawl errors using Drupal’s built-in reports for "Top ‘page not found’ errors" and "Top ‘access denied’ errors" at /admin/reports/page-not-found and /admin/reports/access-denied.
  5. Use the Redirect 404 module to find, sort, and manage all 404 errors on your site, making it easier to create redirects.
  6. Leverage external tools like Google Search Console to identify 404, 403, 500, and other errors, submit XML sitemaps to improve indexing, and use SEO spiders like Screaming Frog to detect hidden crawl errors.
  7. Plan your site structure carefully, back up your site regularly, stay informed about Drupal updates, and avoid hardcoding or unsafe PHP snippets to maintain site stability and security.
  8. Implement server-level protections (e.g., mod_security) to block malicious repeated 404 requests efficiently, rather than relying solely on Drupal modules.
  9. Establish a regular maintenance schedule with reminders to review and address crawl errors to keep your website healthy and SEO-friendly.

These practices help not only to fix current 404 errors but also to prevent their recurrence, ensuring a better user experience and improved search engine rankings on Drupal platforms. (volacci.com, drupal.org)

Prevention Checklist

  • Install and configure the Pathauto module to create SEO-friendly URL aliases, preventing default node paths that cause 404 errors.
  • Use the Redirect module to automatically create 301 redirects when content URLs change and manually fix crawl errors by setting redirects for broken URLs.
  • Implement the Search 404 module to redirect visitors from non-existent pages to relevant internal search results, reducing bounce rates.
  • Regularly monitor Drupal’s built-in reports for ‘Top page not found’ and ‘Top access denied’ errors to identify and address crawl errors promptly.
  • Use the Redirect 404 module to find, sort, and manage all 404 errors on your site, facilitating easy redirect creation.
  • Submit XML sitemaps to Google Search Console and use it to monitor and fix crawl errors including 404, 403, and 500 errors.
  • Run periodic site crawls with tools like Screaming Frog SEO Spider to detect hidden crawl errors and SEO issues.
  • Maintain a regular schedule for reviewing and fixing crawl errors (daily, weekly, monthly, quarterly, annually) to keep your Drupal site SEO healthy.

Ongoing Maintenance and Monitoring

To prevent the recurrence of 404 errors on your Drupal website, implement ongoing monitoring and maintenance practices such as regularly checking the Status Report screen to monitor site health, configuring Drupal Cron jobs to automate tasks like indexing and updates, auditing user roles and permissions to ensure proper access, and monitoring uptime and performance with tools like New Relic APM. Use the Drupal Redirect module to log and fix 404 errors by setting up redirects for deleted or moved pages, and employ the Fast 404 module to quickly serve 404 responses, enhancing user experience and site performance. These steps help minimize broken links, improve SEO, and maintain a seamless user experience on your Drupal site. (Acquia)

Who Should Use This Guide

  • Webmasters managing Drupal websites
  • Site owners using Drupal as their CMS
  • Digital marketers focused on Drupal SEO
  • SEO professionals optimizing Drupal sites
  • Developers responsible for Drupal site maintenance

Related Blog Posts