Black Friday Black FridayUp to 85% off all WP Ghost plans.48 months from $49, or pay once for lifetime. SHOP NOW

Does WP Ghost Make Changes to the .htaccess File?

Moved

This tutorial has moved to the new WP Ghost Knowledge Base where each feature is presented in detail.

View on new site

Yes. On Apache and LiteSpeed, WP Ghost writes its rewrite rules (and, if you choose, its firewall rules) to .htaccess, the same file WordPress uses for permalinks. It doesn’t edit WordPress PHP files, and it removes its rules when you deactivate it.

What exactly does WP Ghost add to .htaccess?

WP Ghost adds two types of rules to your .htaccess file. The first is URL rewrite rules that map your custom paths (like a custom login URL or custom wp-content path) to the original WordPress file locations. The second, when Firewall Location is set to In .htaccess file, is the firewall rules for your chosen Firewall Strength (2026 Ghost Firewall is the recommended level). They block malicious requests at the server level before PHP loads.

The path rules sit between # BEGIN HMWP_RULES and # END HMWP_RULES. Firewall rules written to .htaccess get their own block, # BEGIN HMWP_VULNERABILITY to # END HMWP_VULNERABILITY. The markers keep WP Ghost’s rules apart from the WordPress core rules and from other plugins’ rules.

Does WP Ghost change any files besides .htaccess?

On Apache and LiteSpeed, .htaccess is the only server file WP Ghost writes to. It doesn’t modify wp-settings.php, theme files or other plugins’ files, and the rewrites happen when a browser requests a URL, without moving anything on disk. Two PHP writes are opt-in: with Must Use Plugin Loading on (WP Ghost > Advanced > Compatibility), WP Ghost adds the loader file wp-content/mu-plugins/0-hidemywp.php and removes it on deactivation, and the Security Check fixes for the salt keys and the database prefix write their new values to wp-config.php when you run them.

On Nginx servers, WP Ghost generates a separate hidemywp.conf file instead. On Windows IIS servers, it provides rules for web.config. In all cases, only server configuration files are touched, never WordPress core files.

What happens to .htaccess when I deactivate WP Ghost?

WP Ghost removes its rules from .htaccess automatically when you deactivate the plugin. Its marked blocks are deleted, and .htaccess goes back to the WordPress core permalink rules and any rules from your other plugins. No manual cleanup is needed.

Can other plugins remove WP Ghost’s .htaccess rules?

Some security or optimization plugins clean up custom rules in .htaccess that sit outside the WordPress block (#BEGIN WordPress / #END WordPress). If you notice your custom paths stop working after saving another plugin’s settings, that plugin may be removing WP Ghost’s rules.

The fix is to go to WP Ghost > Advanced > Compatibility and enable Add Rewrites in WordPress Rules Section. This moves WP Ghost’s rules inside the WordPress block where they’re protected from deletion by other plugins. Alternatively, you can set your .htaccess file permissions to read-only (444) after saving WP Ghost settings to prevent any plugin from modifying it. For details, see the .htaccess read-only guide.

Frequently asked questions

Is writing to .htaccess safe?

Yes. Writing URL rewrite rules and security filters to .htaccess is the standard method used by WordPress itself and by every major plugin that handles permalinks, caching, or security on Apache/LiteSpeed servers. WP Ghost follows the same pattern and uses clearly marked comment blocks to keep its rules separate and identifiable.

What if my .htaccess file isn’t writable?

If .htaccess is set to read-only (which is actually good security practice), WP Ghost will show you the rules that need to be added manually. You can temporarily change the file permissions, save WP Ghost settings, then set it back to read-only. Or you can copy the rules from the WP Ghost notification and paste them into .htaccess manually via FTP or your hosting file manager.

Does WP Ghost require AllowOverride All?

Yes, on Apache servers. AllowOverride All tells Apache to process the .htaccess file. Most shared hosting plans have this enabled by default. If it’s not enabled, WP Ghost’s rewrite rules are ignored and the plugin falls back to slower WordPress PHP redirects. See the AllowOverride setup guide if you need to enable it.

What about Nginx? Does WP Ghost modify nginx.conf?

WP Ghost doesn’t write to nginx.conf directly. It generates a separate hidemywp.conf file that you (or your host) include in the Nginx configuration. This is a one-time setup. For the full process, see the Nginx setup guide.

Does WP Ghost modify WordPress core files?

No. WP Ghost writes to .htaccess (a server config file, not a WordPress core file) and uses WordPress runtime filters for application-level changes. No PHP files, theme files, or plugin files are ever modified. Deactivating removes all rules and restores defaults instantly.