How Do I Fix a Broken .htaccess in WooCommerce?

Why This Happens

The .htaccess file, on Apache-based hosting, contains the rewrite rules that translate clean, readable URLs into the actual WordPress page requests behind them. This file can go missing or become corrupted from a server migration, a hosting-side reset, a security plugin's own rewrite rules conflicting with WordPress's, or simply a manual editing mistake — and when it's broken, nearly every non-homepage URL on the site can start returning a 404, WooCommerce pages included.

Common Causes

  • A server migration or restore that didn't correctly transfer the existing .htaccess file, or reset it to a generic default.
  • A security plugin or CDN writing its own rules into .htaccess in a way that conflicts with or overwrites WordPress's expected block.
  • Manual editing (adding a custom rule, a redirect) that introduced a syntax error, breaking the whole file's processing.
  • File permission issues preventing WordPress from writing to the file when it needs to regenerate rules automatically.

How to Fix It

  1. Go to Settings → Permalinks and click Save without changing anything — this forces WordPress to regenerate its standard rewrite block, resolving most cases.
  2. If that doesn't work, check file permissions on .htaccess and its containing directory, ensuring WordPress can actually write to it.
  3. If a plugin's own rules are suspected of conflicting, temporarily deactivate it and regenerate permalinks again to test.
  4. As a last resort, manually recreate the file with WordPress's standard rewrite block, available in the WordPress documentation, then re-add any legitimate custom rules afterward.

Site returning widespread 404 errors and need this fixed urgently? See WooCommerce fixes.

Safely testing and replacing .htaccess

  1. Download a copy first through FTP or the host's file manager, so any change can be undone.
  2. Rename the file and test. Rename .htaccess to .htaccess-old and load the site. If a 500 error disappears, the old file had a syntax error, and the server's error log will name the line. If the homepage loads but inner pages return 404, save the Permalinks screen to write a fresh file.
  3. Know the standard block. A default WordPress install uses:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  4. Check which server you're on. Nginx doesn't read .htaccess at all. If the host runs Nginx, editing the file changes nothing, and the equivalent rule lives in the server configuration.

Available for new projects

NEXT STEP

Rather have it fixed than keep reading?

Based in Dhaka, Bangladesh — serving clients worldwide. Tell me what's happening and you'll have a reply within one working day.

  • Reply within one working day
  • Fixed quote before work starts
  • UK, EU and US hours covered