Move WP Ghost’s Nginx rewrite rules to a custom location when your website root directory isn’t writable. By default, WP Ghost writes its Nginx rewrite rules to hidemywp.conf in your WordPress root. If your root directory has restricted permissions (common on managed hosting or hardened servers), WP Ghost can’t write to it. The solution is to relocate the config file to a writable directory like wp-content/, then tell both Nginx and WP Ghost to use the new location. This guide walks through all four steps: creating the file, updating the Nginx server block, adding the WP Ghost filter, and restarting Nginx.
When You Need a Custom Config File

Most Nginx setups let WP Ghost write rewrite rules directly to the WordPress root as hidemywp.conf. But on hardened servers and many managed hosts, the root directory is read-only for the PHP process. WP Ghost detects this and shows a notification asking you to add the config manually. Instead of editing rules every time you save WP Ghost settings, this approach gives WP Ghost a writable location it can update automatically. You configure it once, then WP Ghost handles the rest.
This guide is for self-hosted Nginx servers where you have shell access. For managed hosting where you can’t edit Nginx config files at all, see Use WP Ghost on Nginx Without Config Changes.
Create the Custom Config File
- Connect to your server via SSH.
cd /path/to/wordpress/wp-content/- Create the empty config file:
touch hidemywp_custom.conf- Make sure the file is writable by the web server user (usually
www-dataon Ubuntu/Debian,nginxon CentOS/RHEL):
sudo chown www-data:www-data hidemywp_custom.conf
sudo chmod 644 hidemywp_custom.confReplace the path: Use your actual WordPress installation path instead of /path/to/wordpress/. Common paths include /var/www/html/, /var/www/yoursite.com/, or /home/username/public_html/ depending on your hosting setup.
Update the Nginx Server Block
Now tell Nginx to load this file as part of your site’s configuration. The Nginx config is typically at /etc/nginx/nginx.conf or in a virtual host file under /etc/nginx/sites-available/ or /etc/nginx/conf.d/.
- Open your Nginx server block configuration with a text editor:
sudo nano /etc/nginx/sites-available/yoursite.com- Inside the
server { ... }block, add the include directive pointing to your custom config file:
server {
# Other existing configurations...
include /path/to/wordpress/wp-content/hidemywp_custom.conf;
# Other existing configurations...
}- Save the file.
- Test the Nginx configuration syntax before reloading:
sudo nginx -tIf you see syntax is ok and test is successful, you’re ready to proceed. If you see errors, fix them before continuing – a syntax error will prevent Nginx from starting.
Tell WP Ghost to Use the New File
Add a filter to wp-config.php that tells WP Ghost to write its rules to your custom file instead of the default location.
- Open
wp-config.phpin your WordPress root directory. - Add this code at the end of the file (before the line
/* That's all, stop editing! */):
add_filter( 'hmwp_config_file', function() {
return ABSPATH . 'wp-content/hidemywp_custom.conf';
} );- Save
wp-config.php.

Important: Always back up wp-config.php before editing it. A typo or missing semicolon in this file can break your entire site. If something goes wrong, restore the backup via FTP or SSH.
Save WP Ghost Settings and Restart Nginx
- Log in to your WordPress dashboard.
- Go to WP Ghost > Change Paths.
- Click Save. WP Ghost writes its rewrite rules to your custom config file.
- Reload Nginx to apply the new rules:
sudo systemctl reload nginxReload vs restart: reload applies the new config without dropping active connections, which is preferred for production sites. Use sudo systemctl restart nginx only if reload doesn’t work. On older systems without systemd, use sudo service nginx reload.
Test that your site loads correctly and that custom WP Ghost paths work. Every time you save WP Ghost settings in the future, you must reload Nginx for the new rules to take effect:
sudo systemctl reload nginxTroubleshooting
Nginx fails to reload with “open() failed” error
Nginx can’t read the custom config file. Check the file path in your include directive matches the actual file location, and verify file permissions allow Nginx to read it: sudo chmod 644 /path/to/wordpress/wp-content/hidemywp_custom.conf. The Nginx user must have read access.
WP Ghost still shows the “config file not writable” notification
The file owner is wrong. PHP needs to write to this file, so it must be owned by the web server user. Run sudo chown www-data:www-data /path/to/wordpress/wp-content/hidemywp_custom.conf on Ubuntu/Debian or sudo chown nginx:nginx ... on CentOS/RHEL. Find your web server user with ps aux | grep nginx.
Custom paths return 404 after saving WP Ghost
You probably forgot to reload Nginx. WP Ghost wrote the new rules to the config file, but Nginx is still running with the old configuration in memory. Run sudo systemctl reload nginx. If the issue persists, check that the include directive is inside the server { ... } block (not outside it) and that the path matches.
Nginx test fails after editing the server block
Run sudo nginx -t and read the specific error message. Common issues: missing semicolon at the end of the include line, the include line placed outside the server block, or the path containing spaces or special characters. Fix the syntax and test again before reloading.
Frequently Asked Questions
When do I actually need this?
You need this only if WP Ghost shows a notification that it can’t write to the default config location. On most Nginx setups with standard permissions, this isn’t necessary – WP Ghost writes hidemywp.conf to the WordPress root directly. This guide is for hardened servers, certain managed hosts, or environments where the root is read-only for the PHP process.
Do I need to reload Nginx every time I save WP Ghost settings?
Yes. Nginx loads its configuration at startup and keeps it in memory. Any change to the rewrite rules – whether automatic from WP Ghost or manual – requires a reload to take effect: sudo systemctl reload nginx. This is different from Apache, which can re-read .htaccess on every request.
Can I put the file in a different location?
Yes. The wp-content directory is the recommended location because it’s part of WordPress and survives core updates, but you can use any path that’s writable by PHP and readable by Nginx. Update both the include directive in the Nginx server block and the path returned by the hmwp_config_file filter to match.
What about managed hosting where I can’t edit Nginx config?
This guide requires shell access and the ability to edit Nginx config files. If you’re on managed hosting (Kinsta, WP Engine, Flywheel, SiteGround) where these aren’t available, see Use WP Ghost on Nginx Without Config Changes for the features that work without server-level configuration.
Does WP Ghost modify WordPress core files?
No. The hmwp_config_file filter is added to wp-config.php, which is your site’s configuration file – not a WordPress core file. WP Ghost itself doesn’t modify any core files. The custom config file is a separate file that lives in wp-content.
Related Tutorials
Nginx and server configuration:
- Setup WP Ghost on Nginx Server – Standard Nginx configuration for WP Ghost.
- Use WP Ghost on Nginx Without Config Changes – For managed hosting environments.
- Set AllowOverride All on Apache – Apache equivalent for enabling rewrite rules.
- Server Types – All server types supported by WP Ghost.
- Emergency Disable – Recovery if rewrite rules cause issues.
