How to Remove WP Ghost Rewrite Rules from WordPress .htaccess?

Moved

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

View on new site

Go to WP Ghost > Advanced > Compatibility and switch off “Add Rewrites in WordPress Rules Section.” Click Save. This removes WP Ghost’s rewrite rules from the # BEGIN WordPress … # END WordPress block in .htaccess and keeps them only in the dedicated # BEGIN HMWP_RULES … # END HMWP_RULES section.

Why WP Ghost Adds Rules in Two Places

By default, WP Ghost writes its rewrite rules in two locations inside your .htaccess file: its own # BEGIN HMWP_RULES block and inside the # BEGIN WordPress block. This dual placement is a safety measure. Some plugins and WordPress itself can regenerate the WordPress rewrite block when saving permalinks, which would delete any WP Ghost rules placed only in the WordPress section. By keeping a separate HMWP_RULES block, WP Ghost’s rules survive even if the WordPress block is regenerated.

However, there are situations where you want WP Ghost’s rules in only one place. Some hosting environments or other plugins may conflict with duplicate rewrite rules. Caching or optimization plugins that parse .htaccess may behave unexpectedly when the same rules appear twice. In these cases, removing the rules from the WordPress block keeps your .htaccess clean and avoids potential conflicts.

How to Remove the Rules from the WordPress Block

You have two options, both achieve the same result.

Option 1: Dashboard setting (recommended). Go to WP Ghost > Advanced > Compatibility. Switch off the option Add Rewrites in WordPress Rules Section. Click Save. WP Ghost will automatically remove its rules from the # BEGIN WordPress block and keep them only in the # BEGIN HMWP_RULES section.

Option 2: wp-config.php constant. If you prefer to set this at the server level, add the following line to your wp-config.php file before the /* That's all, stop editing! */ comment:

define( 'HMW_RULES_IN_WP_RULES', false );

After adding the constant, go to WP Ghost > Change Paths and click Save to regenerate the .htaccess file with the updated rule placement. For the full list of wp-config.php constants, see the WP Ghost Constants tutorial.

Frequently Asked Questions

Will removing rules from the WordPress block break my path security?

No. The rules in the # BEGIN HMWP_RULES block handle all path changes independently. Removing the duplicate from the WordPress block has no effect on your security configuration. Both blocks contain identical rules, so keeping one is sufficient.

What if another plugin deletes the HMWP_RULES block?

This is rare, but possible with aggressive .htaccess management plugins. If the HMWP_RULES block gets removed, go to WP Ghost > Change Paths and click Save to regenerate it. WP Ghost rewrites its rules every time you save settings. If you experience this repeatedly, consider re-enabling the “Add Rewrites in WordPress Rules Section” option as a backup.

Does this apply to Nginx servers?

No. Nginx does not use .htaccess files. WP Ghost writes Nginx rewrite rules to a separate configuration file that you include in your Nginx server block. The “Add Rewrites in WordPress Rules Section” setting only affects Apache and LiteSpeed servers that use .htaccess. See the Nginx setup guide for Nginx-specific configuration.

Does WP Ghost modify WordPress core files?

No. WP Ghost writes rewrite rules to .htaccess (Apache/LiteSpeed) or a separate config file (Nginx). No WordPress core files are modified. The .htaccess file is a standard Apache configuration file, not a WordPress core file. Deactivating WP Ghost removes its rules from .htaccess automatically.