Troubleshooting

Preventing 404 Errors After Deactivating WP Ghost

If you deactivate WP Ghost after using custom paths (Safe Mode or Ghost Mode), search engines and external sites may still link to your content using the old custom URLs. Those URLs now return 404 errors because the rewrite rules that mapped them to real WordPress paths are no longer active. To prevent 404 errors, add redirect rules to your server configuration that map the custom paths back to the original WordPress paths.

Apache (.htaccess)

Open the .htaccess file in the root directory of your WordPress installation. Add the following rewrite rules at the beginning of the file, before the WordPress rewrite block. Replace the custom path names (core, storage, lib, core/views) with the actual custom paths you used in WP Ghost:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([_0-9a-zA-Z-]+/)?core/views/(.*) /wp-content/themes/$2 [QSA,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?storage/(.*) /wp-content/uploads/$2 [QSA,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?core/(.*) /wp-content/$2 [QSA,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?lib/(.*) /wp-includes/$2 [QSA,L]
</IfModule>

Save the file and test your site. Custom path URLs should now redirect to the correct WordPress paths.

Nginx

Open your Nginx configuration file (usually at /etc/nginx/ or within your site’s server block). Add the following rules inside the server block. Replace the custom path names with the ones you used:

if (!-e $request_filename) {
    rewrite ^/([_0-9a-zA-Z-]+/)?core/views/(.*) /wp-content/themes/$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?storage/(.*) /wp-content/uploads/$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?core/(.*) /wp-content/$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?lib/(.*) /wp-includes/$2 last;
}

Save the file and reload Nginx: sudo systemctl reload nginx.

Important notes

The example rules above use core, storage, lib, and core/views as custom paths. If you used different names in WP Ghost (like assets, media, includes), replace them in the rules accordingly. These redirect rules can be removed once search engines have re-indexed your site with the original WordPress paths (typically a few weeks to months). Back up your .htaccess or nginx.conf before making changes.

If you need to check what custom paths you had configured, reinstall WP Ghost temporarily (without activating any mode) and check WP Ghost > Change Paths for the saved path values. If you’ve lost access to the admin dashboard, see the emergency disable guide.

John Darrel

Change the WordPress Database Prefix for Security

Replace the default wp_ database prefix with a random one to protect against SQL injection…

1 year

Customize WordPress Uploads Directory | WP Ghost

Change the WordPress uploads directory path with WP Ghost (rewrite rules, no files moved) or…

1 year

WP Ghost and WP Rocket Cache Setup Guide

Configure WP Ghost with WP Rocket cache. Enable file optimization, Change Paths in Cache Files.…

1 year

Why is website security important?

https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…

1 year

Is WordPress Website Easily Hacked?

The security of your WordPress site depends on multiple factors, such as the strength of…

1 year

Set Up WordPress 2FA with Mobile Authenticator Apps

Step-by-step guides to connect WP Ghost 2FA with Google Authenticator, Authy, Microsoft Authenticator, or LastPass.…

1 year