Skip to content Skip to main navigation Skip to footer

Set Up WP Ghost on Nginx Server – Include hidemywp.conf Configuration

Moved

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

View on new site

Set up WP Ghost (formerly Hide My WP Ghost) on an Nginx server by adding one include line to your server block config. WP Ghost generates a hidemywp.conf file with all the rewrite rules. You include it in your Nginx configuration and restart. This is a one-time setup step.

Why Nginx Needs Manual Setup

On Apache servers, WP Ghost writes rewrite rules to .htaccess automatically. Nginx does not support .htaccess files. Instead, all rewrite rules must be included in the Nginx server block configuration. WP Ghost generates a file called hidemywp.conf containing all the rules. You add one include line to your Nginx config, and WP Ghost updates the conf file automatically whenever you change settings. You only need to reload Nginx after the initial setup.


How to Configure WP Ghost on Nginx

Step 1: Activate a Security Level in WP Ghost

Go to WP Ghost > Change Paths > Level of Security. Select Safe Mode or Ghost Mode. Click Save.

After saving, WP Ghost displays a notification with the exact include line you need to add. It also shows the path to the hidemywp.conf file. Copy this line.

Step 2: Find Your Nginx Server Block Config

SSH into your server. Nginx configuration is typically in one of these locations:

/etc/nginx/sites-enabled/ — if your Nginx uses the sites-enabled/sites-available pattern (common on Ubuntu/Debian). Open the file named after your domain.

/etc/nginx/conf.d/ — if your Nginx uses the conf.d pattern. Open the .conf file for your site.

/etc/nginx/nginx.conf — if the server block is defined directly in the main config file (less common).

Find the server { } block for your WordPress site.

Step 3: Add the Include Line

Add the include line before the WordPress rewrite rules (the location / block). Placement matters: if placed after the WordPress rules, they process first and WP Ghost’s path security will not work.

server {
    server_name yourdomain.com;
    root /var/www/yourdomain.com;
    index index.php;

    include path-to-file/hidemywp.conf;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Replace path-to-file/hidemywp.conf with the actual path shown in the WP Ghost notification. Replace yourdomain.com and the root path with your actual values. Do not delete any existing lines from your configuration.

Step 4: Reload Nginx and Test

Test the configuration for syntax errors first:

sudo nginx -t

If it returns syntax is ok, reload Nginx:

sudo nginx -s reload

Go back to WP Ghost and click “Okay, I set it up”. Then run the Frontend Test. Check if the frontend and login pages load correctly. If everything loads, click “Yes, it’s working”. If something is broken, click “No, abort” to roll back.


Troubleshooting

Custom paths return 404 after setup

The include line is missing or placed incorrectly. Verify the include line is inside the correct server block and before the location / block. Confirm Nginx was reloaded after editing. Run sudo nginx -t to check for syntax errors.

Nginx will not reload after editing config

There is a syntax error. Run sudo nginx -t to see the exact error and line number. Common causes: missing semicolon, unclosed bracket, or incorrect path in the include line. Fix the error and try reloading again.

WP Ghost rules not updating after changing settings

WP Ghost updates the hidemywp.conf file automatically when you save settings. However, Nginx does not detect file changes until reloaded. After changing WP Ghost settings that affect rewrite rules, run sudo nginx -s reload again. For most path changes, a reload is not needed because WP Ghost handles them through WordPress hooks. Only structural rewrite rule changes require a reload.

Locked out after configuration

SSH into your server and either remove the include line from your Nginx config and reload, or use the Safe URL parameter, or rename the WP Ghost plugin folder via SFTP. See the Emergency Disable guide.


Frequently Asked Questions

Is this a one-time setup?

Yes. The include line stays in your Nginx config permanently. WP Ghost updates the hidemywp.conf file automatically when you change settings. You only need to reload Nginx after the initial setup or after structural rule changes.

I do not have SSH access to my server. What can I do?

Contact your hosting provider and ask them to add the include line. WP Ghost shows the exact line to add. Most managed Nginx hosts (Kinsta, WP Engine, Flywheel) have support teams that can do this in minutes. Some hosts provide a web-based Nginx config editor in their control panel.

Where does WP Ghost store the hidemywp.conf file?

WP Ghost generates the file inside your WordPress installation directory. The exact path is shown in the notification after you save settings. It is typically in your WordPress root or the wp-content directory. WP Ghost updates this file automatically whenever you change path settings.

Does the include line placement matter?

Yes. The include must be placed before the location / block that contains the WordPress rewrite rules. If placed after, the WordPress rules process first and WP Ghost’s rules are ignored.

Does WP Ghost modify WordPress core files?

No. WP Ghost generates a separate hidemywp.conf file and uses WordPress hooks. No core files are modified. Removing the include line and reloading Nginx restores all default paths.


Google Cloud Platform Setup – server setup for Google Cloud Apache instances.

Set AllowOverride All on Apache – the equivalent setup for Apache servers.

Theme Not Loading Correctly – troubleshoot path issues on Nginx and Apache.

Emergency Disable Guide – recovery via SSH/SFTP if needed.

Customize All WordPress Paths – configure paths after server setup is complete.