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 Write Code into PHP Files?

Moved

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

View on new site

No. WP Ghost doesn’t edit WordPress core, theme or plugin PHP files; it changes paths with server rewrite rules and WordPress filters. The two exceptions are opt-in: a small must-use loader file when Must Use Plugin Loading is on, and wp-config.php when you run the Security Check fixes for the salt keys or the database prefix.

How does WP Ghost change paths without modifying PHP files?

WP Ghost uses two mechanisms to change your WordPress paths, and neither one touches your PHP files.

The first is server rewrite rules. On Apache and LiteSpeed servers, WP Ghost writes URL rewrite rules to the .htaccess file. This is a server configuration file, not a PHP file. It tells the web server how to route requests from the new custom paths to the original file locations. On Nginx servers, WP Ghost generates a hidemywp.conf file that you (or your host) include in the Nginx configuration. On Windows IIS servers, WP Ghost provides rules for the web.config file.

The second is WordPress runtime filters. WP Ghost hooks into WordPress using standard WordPress filters and actions. These are the same hooks that every WordPress plugin uses. They modify the HTML output as WordPress generates pages, changing path references in the source code on the fly. The actual files on disk are never touched.

What files does WP Ghost actually write to?

WP Ghost writes to these places, none of them WordPress core files:

Server configuration files: .htaccess on Apache/LiteSpeed, hidemywp.conf for Nginx inclusion, or web.config on Windows IIS. These contain URL rewrite rules that the web server processes. WordPress itself uses .htaccess for permalink rules, and WP Ghost follows the same pattern.

Plugin settings in the WordPress database: All of WP Ghost’s configuration (custom paths, firewall settings, mapping rules, etc.) is stored in the WordPress options table, just like any other plugin’s settings.

Two opt-in PHP files: with Must Use Plugin Loading on (WP Ghost > Advanced > Compatibility), WP Ghost adds wp-content/mu-plugins/0-hidemywp.php so it loads before other plugins, and removes it on deactivation. If you run the Security Check fixes for the salt keys or the database prefix, WP Ghost writes the new values to wp-config.php. Apart from that, wp-settings.php, wp-load.php, your theme’s functions.php and your plugin files stay as they were before WP Ghost was installed.

What happens when I deactivate WP Ghost?

Everything reverts instantly. WP Ghost removes its rewrite rules from .htaccess (or the equivalent config file) and stops processing WordPress filters. Your site returns to its exact state before WP Ghost was installed. All default WordPress paths (/wp-admin, /wp-login.php, /wp-content/, /wp-includes/) become active again. No cleanup needed, no leftover code, no orphaned files.

If you delete the plugin, its settings are removed from the database too. The log table and temporary logins are removed only when Delete Temporary Users on Plugin Uninstall is on in the Temporary Logins settings.

Does WP Ghost affect my file structure on FTP?

No. If you connect to your site via FTP or a hosting file manager, you’ll see the standard WordPress directory structure exactly as it was before WP Ghost: /wp-admin/, /wp-content/, /wp-includes/, and all plugin and theme folders in their original locations with their original names. WP Ghost creates virtual paths through URL rewriting, not physical file changes. The files stay where WordPress put them.

Frequently asked questions

Does WP Ghost write to .htaccess? Is that safe?

Yes, WP Ghost writes rewrite rules to .htaccess on Apache and LiteSpeed servers. This is the standard way to handle URL rewriting in WordPress; WordPress core writes its permalink rules to the same file. The path rules sit between # BEGIN HMWP_RULES and # END HMWP_RULES (firewall rules get their own HMWP_VULNERABILITY block), and both are removed on deactivation.

Will WP Ghost leave behind any code if I uninstall it?

No code is left behind. Deactivating removes the rewrite rules and the must-use loader, and deleting the plugin removes its settings. The log table and temporary logins stay unless Delete Temporary Users on Plugin Uninstall is on.

Can WP Ghost break my site if something goes wrong?

Because WP Ghost doesn’t modify PHP files, any issue is fully reversible. If something stops working, you can use the emergency disable method (rename the plugin folder via FTP) to instantly restore all defaults. No file repair or code cleanup is ever needed.

Is this different from other security plugins that modify files?

Some security plugins write code into wp-config.php or create .user.ini files. WP Ghost keeps its changes in server rewrite rules and WordPress hooks, and it writes to wp-config.php only when you run the salt or database prefix fix yourself. That means fewer compatibility issues, easier troubleshooting and a clean uninstall.

Does WP Ghost modify WordPress core files?

No. WP Ghost never modifies, moves, or renames any WordPress core file, theme file, or plugin file. All path changes use server rewrite rules and WordPress filters at runtime. Deactivating the plugin restores all default WordPress paths instantly.