How Do I Hide Old WordPress Image Paths?
This tutorial has moved to the new WP Ghost Knowledge Base where each feature is presented in detail.
By default, WP Ghost does not hide image file extensions from old paths because blocking them can break images already indexed in Google Image Search. If you still want to hide the old image paths (returning a 404 for the original URLs), you can enable it with a wp-config.php constant. Alternatively, you can redirect old image paths to the new ones so external links keep working. This guide covers both approaches and when to use each.
Why Doesn’t WP Ghost Hide Old Image Paths by Default?
Images don’t represent a direct security risk for your site the way PHP files or JavaScript files do. Hiding them is not necessary to increase your WordPress protection. The main reason WP Ghost excludes images from the Hide File Extensions list by default is SEO: if Google has already indexed your images under the old /wp-content/uploads/ paths, hiding them returns a 404 error. Anyone landing on your site through Google Images would see a broken page.
Even without hiding images, Google will eventually re-index all your media with the new custom paths over time. If you want to speed that process up, resubmit your sitemap in Google Search Console after changing your uploads path.
How Do I Hide Old Image Paths (Return a 404)?
If you want the old image URLs to return a 404 error (maximum security, but breaks old external links to your images), you need to add a constant to wp-config.php first, then select the IMAGE files option in WP Ghost.
Open your wp-config.php file via FTP or your hosting file manager and add this line before /* That's all, stop editing! */:
define('HMW_HIDE_OLD_IMAGES', true);
After saving the file, go to WP Ghost > Change Paths > WP Core Security > Hide WordPress Common Paths > Hide File Extensions. You’ll now see the IMAGE Files option in the list. The image extensions covered are jpeg, jpg, tiff, gif, bmp, png, and webp.

Select IMAGE Files and click Save. Old image URLs through /wp-content/uploads/ will now return a 404 error. Images will only load through the new custom uploads path.
How Do I Redirect Old Image Paths to the New Ones Instead?
If external sites, social media posts, or email newsletters link to your images using the old /wp-content/uploads/ URLs, hiding those paths with a 404 breaks all those links. A better option is to redirect old URLs to the new custom path. The image still loads, the link still works, and the WordPress path disappears.

There are two approaches: using WP Ghost’s built-in MEDIA Files redirect, or adding manual server rewrite rules.
Option A – Use WP Ghost’s Built-In Redirect
First, set a custom uploads path. Go to WP Ghost > Change Paths > WP Core Security and enter a directory name (like “storage”) in the Custom Uploads Path field. Click Save.

Then enable the redirect. In the same WP Core Security section, enable Hide WordPress Common Paths. Under Hide File Extensions, select MEDIA Files from the list. Click Save. Old image URLs now redirect to the new path automatically.
For the full redirect tutorial with additional details, see the redirect images from old paths guide.
Option B – Manual Server Rewrite Rules
If you need more control over the redirect behavior, you can add rewrite rules directly to your server config.
For Apache/LiteSpeed, add this code at the beginning of your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} /wp-content/uploads/[^\.]+(\.jpg|\.png|\.jpeg|\.webp|\.gif) [NC]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-content/uploads/(.*)$ /storage/$2 [L,R=301]
</IfModule>For Nginx servers, add this code before the WP Ghost include line in your Nginx config file:
if ($request_uri ~* ^/wp-content/uploads/[^\.]+(\.jpg|\.png|\.jpeg|\.webp|\.gif)){
rewrite ^/wp-content/uploads/(.*)$ /storage/$1 redirect;
}Replace /storage/ in the examples above with whatever custom uploads path you set in WP Ghost. These rules check if the request is for an image file in the old /wp-content/uploads/ directory and issue a 301 redirect to the new path.
Which Approach Should I Use – Hiding or Redirecting?
Redirecting is the better choice for most sites. It sends requests from the old URL to the new one, preserving external links, avoiding broken images, and consolidating SEO signals to a single URL. Hiding (returning a 404) is for situations where you want maximum security and don’t mind that old external links to your images will break. If Google has already indexed your images, hiding can temporarily result in 404 errors in Google Image Search until the new paths are indexed.
Frequently Asked Questions
Will hiding old image paths hurt my image SEO?
It can temporarily. If Google has indexed images under the old paths, hiding them returns 404 errors until Google re-indexes the new URLs. Resubmit your sitemap in Google Search Console to speed this up. Redirecting (instead of hiding) avoids this issue entirely because Google follows the redirect and updates its index to the new URL.
What if my theme loads images through CSS or JS files?
If your theme or plugins reference images inside CSS or JavaScript files using the old paths, those images may stop loading after you hide the old paths. The fix is to use a caching plugin and enable Change Paths in Cached Files under WP Ghost > Tweaks. This ensures the new paths are written into cached CSS and JS files.
Does this work with CDNs?
Yes, but make sure your CDN is configured to serve from the new path. If your CDN still caches images under the old /wp-content/uploads/ path, purge the CDN cache after making the change. For CDN configuration, see the CDN URL Mapping tutorial.
Does this work with WooCommerce product images?
Yes. WooCommerce stores product images in wp-content/uploads/ like all WordPress media. Both hiding and redirecting apply to all media files including product images, gallery thumbnails, and downloadable files. WP Ghost is fully compatible with WooCommerce.
Does WP Ghost physically move my images?
No. WP Ghost never moves, renames, or modifies any file. Your images stay in wp-content/uploads/ exactly where WordPress put them. Path changes and redirects are handled through URL rewrite rules. Deactivating WP Ghost restores all original paths instantly.