.htaccess & Permalinks

WordPress .htaccess Keeps Getting Overwritten by Plugins

A practical guide to finding which WordPress tool owns .htaccess changes, where to put custom rules, and how to stop repeat overwrite surprises.

WordPress .htaccess Keeps Getting Overwritten by Plugins topic illustration

Quick answer

Back up the current `.htaccess`, identify which plugin or WordPress action last wrote to it, keep custom rules outside managed blocks, avoid making the file read-only as a first fix, and move durable rules into host/server configuration when you have that access.

Problem, cause, fix, verify

Problem

Back up the current `.htaccess`, identify which plugin or WordPress action last wrote to it, keep custom rules outside managed blocks, avoid making the file read-only as a first fix, and move durable rules into host/server configuration when you have that access.

Why it matters

Configuration, logs, status codes, and source-backed implementation details.

Safe check

Read logs and order notes

Verify

Avoid broad changes without a rollback path

Editorial trust

Last reviewed
Next review
Sources
3 cited references
Review editorial policy

Technical reference

Check evidence before changing configuration

Configuration, logs, status codes, and source-backed implementation details.

.htaccess & Permalinks
Read logs and order notes
Compare staging with production
Avoid broad changes without a rollback path

What to confirm first

A WordPress `.htaccess` file is not supposed to feel mysterious. It sits in the site root on Apache-style hosting and tells the server how to handle rewrites, redirects, and some access rules. The frustration starts when you add a custom rule, the site works for a while, and then the rule disappears after saving permalinks, clearing cache, changing a security setting, or updating a redirect plugin.

The wrong response is to keep pasting the same rule back into the file. A repeat overwrite means two or more owners are competing: WordPress core, a plugin, hosting control panel tooling, a cache layer, a security feature, or a manual server change. The real fix is to identify the owner of each block, move custom rules to the safest place, and make the next change traceable.

Symptoms to Confirm

  • Permalinks or custom post type URLs work until the file is rewritten, then return 404 or redirect unexpectedly.
  • Custom redirect, cache, security, or header rules disappear after saving a plugin setting.
  • The `# BEGIN WordPress` and `# END WordPress` block changes after saving Permalinks.
  • Cache, security, multilingual, membership, or redirect plugins add their own named blocks.
  • The file timestamp changes even though nobody manually edited it.
  • Making the file read-only seems to stop overwrites, but plugin features or permalink updates start failing.

Why .htaccess Gets Rewritten

WordPress uses `.htaccess` on Apache-style environments to support pretty permalinks. The WordPress documentation describes it as the file WordPress modifies so Apache can serve files from the root directory and route pretty permalink requests correctly. That means saving permalink settings can legitimately rewrite the WordPress-managed block.

Plugins can also write rules when they manage redirects, firewall behavior, brute-force protection, cache bypasses, compression, hotlink protection, multilingual paths, membership access, or custom content routes. Some plugins clearly mark their block. Others modify a known section or regenerate the entire file from their settings.

Apache documentation is blunt about the larger architecture: if you have access to the main server configuration, server config is preferred over `.htaccess` for performance and control. On managed hosting, you may not have that access, so `.htaccess` remains common. That is why ownership notes matter: the file is a shared surface, not a scratchpad.

How to Find the Writer

  1. Download or copy the current `.htaccess` before making any change. Keep the timestamp and the exact file content.
  2. Search the file for named blocks such as WordPress, cache plugin names, security plugin names, redirect tools, or host-added comments.
  3. Trigger one suspected action at a time: save permalinks, save the cache plugin settings, save the security plugin settings, change the redirect plugin settings, or clear a host cache.
  4. After each action, compare the file against the backup. A small diff tells you much more than a broad plugin deactivation test.
  5. Check the server error log when the site returns 500 errors. Apache notes that invalid or disallowed directives in `.htaccess` are usually reported there.
  6. Confirm whether the site actually uses Apache `.htaccess`. Nginx-only hosting does not honor this file the same way, so a visible `.htaccess` file may not be the active owner of routing.

How to Fix It Safely

  1. Keep custom rules outside managed blocks. Do not place long-term custom code between `# BEGIN WordPress` and `# END WordPress`, or inside a plugin block that says it is generated.
  2. Document every custom rule with a short owner comment, date, and purpose so the next admin knows why it exists.
  3. Remove duplicate ownership. If a CDN, host, security plugin, and redirect plugin all enforce the same redirect, choose one owner and disable the overlapping feature elsewhere.
  4. Move durable server rules to Apache virtual host or server configuration when you control the server. That reduces rewrite churn and avoids per-request `.htaccess` overhead.
  5. For managed hosting, ask support which directives are allowed by `AllowOverride` and whether the host injects or normalizes rules automatically.
  6. Only make the file read-only after you know which legitimate writers no longer need access. Record that decision because it can affect future permalink, plugin, and migration work.

After the fix, test the exact routes that failed: homepage, posts, pages, custom post types, uploads, login, checkout or forms if relevant, and one URL handled by each custom redirect. A stable `.htaccess` file is useful only if the site behavior is also correct.

Common Mistakes

  • Putting custom rules inside the WordPress-managed permalink block.
  • Making `.htaccess` read-only before checking which plugin needs to write to it.
  • Copying production `.htaccess` into staging without updating host, path, or HTTPS assumptions.
  • Assuming the plugin named in a block is malicious when it may be doing exactly what its settings requested.
  • Forgetting that cache plugins, security plugins, redirect plugins, and hosts can all manage server rules at the same time.
  • Ignoring the server error log after a 500 error caused by an invalid directive.

Support Handoff Checklist

  • Current `.htaccess` backup and the changed version.
  • Exact timestamp when the file changed.
  • Action that triggered the rewrite.
  • Named block or lines that changed.
  • Affected URLs and response codes before and after the change.
  • List of plugins that manage redirects, cache, security, memberships, multilingual routing, or custom post type rewrites.
  • Host/server type and whether Apache `.htaccess` is actually active.

How Web Plura Diagnostics Helps

Web Plura Diagnostics is useful here because `.htaccess` problems rarely live alone. The free plugin provides a local diagnostics dashboard for Site Health-style checks, URL alignment, key file permission signals, hosting readiness, cache signals, plugin/theme impact, front-end response checks, Fix First prioritization, support-safe snapshots, JSON/CSV exports, scheduled local scans, multisite visibility, and WP-CLI output.

It does not edit `.htaccess`, replace server logs, or automatically repair plugin settings. Use it to collect WordPress-side evidence before a host, developer, or plugin vendor handoff. The free plugin is local-first, requires no external account for core diagnostics, and does not send diagnostics telemetry to WPlura by default.

For agencies managing many sites, the Pro and cloud path can add durable cloud history, portfolio monitoring, report delivery, alerting, cross-site prioritization, and hosted correlation after the free local review has established the baseline.

Technical reference support tool

Web Plura Diagnostics

Free local diagnostics for site health, performance, plugin/theme impact, hosting, update risk, cron, front-end response, Fix First prioritization, support-safe snapshots, JSON/CSV exports, scheduled scans, and WP-CLI output.

Reduce repeat incidents

  • Keep an `.htaccess` owner map: WordPress block, cache block, security block, redirect block, host block, and custom rules.
  • Keep custom rules in a versioned snippet or deployment note, not only in the live file.
  • Test permalink saves, cache setting changes, and security setting changes on staging before changing a busy production site.
  • Prefer one redirect owner for each rule: WordPress plugin, host, CDN, or server config.
  • Review `.htaccess` after migrations, SSL changes, CDN changes, and plugin replacements.
  • Use server configuration instead of `.htaccess` for durable rules when you control the server.

References

References

Frequently Asked Questions

Is it safe to make WordPress .htaccess read-only?

Only after you know no legitimate WordPress, plugin, or host workflow still needs to write to it. Making the file read-only too early can break permalink updates, cache features, security settings, or migrations.

Where should I put custom .htaccess rules in WordPress?

Keep custom rules outside generated blocks such as the WordPress permalink block or plugin-managed blocks. Add a short owner comment and keep a copy in your maintenance notes or version control.

Can Web Plura Diagnostics stop .htaccess overwrites automatically?

No. Web Plura Diagnostics helps collect local WordPress health, response, cache, URL, file-permission, and support-safe evidence. The actual rule ownership and file edits still need human review.

Share this guide

Send it to your team