To move WP Ghost’s rewrite rules out of the # BEGIN WordPress block in .htaccess, go to WP Ghost > Advanced > Compatibility and switch off Add Rewrites in WordPress Rules Section, then click Save. WP Ghost will place its rules in its own # BEGIN HMWP_RULES block above the WordPress section, which is the default behavior. You can also set define('HMW_RULES_IN_WP_RULES', false); in your wp-config.php to force the same thing.
Why This Setting Exists
WP Ghost can write its rewrite rules in one of two places inside your .htaccess file. Either inside the # BEGIN WordPress block (mixed in with the core permalink rules), or in its own separate # BEGIN HMWP_RULES block above the WordPress section. Which one is better depends on what else is editing your .htaccess.
The setting you are looking for is called Add Rewrites in WordPress Rules Section. Switch it on and WP Ghost’s rules go inside the WordPress block. Switch it off and they go in their own block. Most sites run fine with it switched off (separate block), which is also the default. You only turn it on when another plugin keeps removing WP Ghost’s rules.
The Three Steps
- Go to WP Ghost > Advanced > Compatibility.
- Switch off Add Rewrites in WordPress Rules Section.
- Click Save.
WP Ghost rewrites the file with its rules in a separate block above the WordPress section, leaving the # BEGIN WordPress and # END WordPress block untouched.
The wp-config.php Alternative
If you would rather enforce this through code, or you want to keep the setting locked even if someone toggles the dashboard option, add a constant to your wp-config.php. Open the file and add this line above the /* That's all, stop editing! */ comment:
define( 'HMW_RULES_IN_WP_RULES', false );Save the file. WP Ghost will ignore the dashboard toggle and always keep its rules outside the WordPress section. Set it to true to force the opposite behavior. For the full list of constants you can use, see the WP Ghost constants in wp-config.php guide.
What the .htaccess File Looks Like Before and After
With the setting switched off (default), your .htaccess looks clean and separated:
# BEGIN HMWP_RULES
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([_0-9a-zA-Z-]+/)?ajax$ /wp-admin/admin-ajax.php [QSA,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?custom-admin/(.*) /wp-admin/$2 [QSA,L]
</IfModule>
# END HMWP_RULES
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPressWith the setting switched on, WP Ghost’s rules are moved inside the # BEGIN WordPress block instead. Both are valid, they just serve different compatibility needs.
When to Use the “On” Setting Instead
You only want WP Ghost’s rules inside the WordPress block when you see a specific pattern: WP Ghost rules keep disappearing from .htaccess. That happens when another plugin cleans up custom rules outside the WordPress section, or when a hosting panel regenerates .htaccess during updates and only preserves the WordPress block. Enabling the option protects the rules by putting them inside that protected section.
If nothing is removing your rules, leave the option off. Keeping WP Ghost’s rules in their own HMWP_RULES block is cleaner, easier to debug, and less likely to cause rule-order conflicts with other plugins that write to the WordPress block. For a deeper look, see the full Rewrites Rules Location guide.
When Does This Apply?
| Server Type | Uses .htaccess? | Does this option apply? |
|---|---|---|
| Apache | Yes | Yes |
| LiteSpeed | Yes (same as Apache) | Yes |
| Nginx | No, uses hidemywp.conf | No |
| IIS / Windows | No, uses web.config | No |
If you are on Nginx, see the Nginx setup guide. The HMW_RULES_IN_WP_RULES constant has no effect on Nginx because Nginx does not use .htaccess.
Frequently Asked Questions
Where does WP Ghost put its rewrite rules by default?
By default, WP Ghost writes its rules in a separate # BEGIN HMWP_RULES block placed above the # BEGIN WordPress section. Apache processes the rules from top to bottom, so WP Ghost’s path rules fire first and the WordPress permalink rules fire afterward. This is the recommended setup for most sites.
Will this break my custom permalinks?
No. The WordPress permalink rules stay exactly where they are, inside the # BEGIN WordPress block. Moving WP Ghost’s rules out of that block actually keeps the WordPress section cleaner and reduces the chance of rule-order issues. If permalinks ever stop working, re-save them under Settings > Permalinks to regenerate the rules.
What is HMW_RULES_IN_WP_RULES and when should I use it?
It is a WordPress constant you can set in wp-config.php to force WP Ghost’s rule placement, bypassing the dashboard setting. Set it to false to always keep the rules in a separate block, or true to always put them inside the WordPress block. Useful for staging environments, deployment scripts, or when you want to lock the setting so it cannot be accidentally changed from the UI.
Does this affect Nginx or IIS servers?
No. This setting only applies to Apache and LiteSpeed, which use .htaccess. Nginx uses a hidemywp.conf include file, and IIS uses web.config. The rule placement option and the HMW_RULES_IN_WP_RULES constant have no effect on those servers.
Another plugin keeps wiping WP Ghost’s rules. What should I do?
Turn the option on (Add Rewrites in WordPress Rules Section) so WP Ghost’s rules move inside the # BEGIN WordPress block, which most plugins leave alone. If the rules still get wiped, the other plugin is rewriting the entire file. Identify the culprit (usually a recently installed security or optimization plugin), configure it to preserve custom rules, or re-save WP Ghost settings after the other plugin runs. Full troubleshooting in the Rewrites Rules Location guide.
What happens to my .htaccess if I deactivate WP Ghost?
WP Ghost automatically removes all its rewrite rules on deactivation, regardless of where they were placed. The # BEGIN HMWP_RULES block disappears, the WordPress block stays untouched, and your site returns to its default configuration. No manual cleanup needed.
Does WP Ghost modify WordPress core files?
No. WP Ghost only writes to .htaccess (Apache and LiteSpeed) or hidemywp.conf (Nginx), which are server configuration files, not WordPress core files. All WP Ghost logic runs through WordPress filters and server rewrite rules. Deactivating WP Ghost restores every default path instantly.