Hide or Redirect Old WordPress Image Paths with WP Ghost
October 21, 2021
This tutorial has moved to the new WP Ghost Knowledge Base where each feature is presented in detail.
Block access to old WordPress image paths after changing the uploads directory with WP Ghost (formerly Hide My WP Ghost). When you change the uploads path, old image URLs may still respond. Hiding them returns a 404 for old paths. Alternatively, redirect old paths to new ones to preserve external links. Images are not a security risk — this is an optional step for maximum CMS hiding.
Before You Start
Images do not represent a security risk for your site. Hiding old image paths is not a necessity and is not something we recommend for protection. It is an optional step for sites that want maximum CMS concealment.
If Google has already indexed your images, hiding old paths means anyone arriving via Google Images will see a 404 error until Google re-indexes with the new paths. Even without hiding, Google will index images at the new paths over time without affecting SEO. Consider using redirects instead of hiding if external sites link to your images.
Option 1: Hide Old Image Paths (404 for Old URLs)
This blocks access to old image URLs entirely. Anyone accessing an old path gets a 404 error.
Add the following line to your wp-config.php file:
define( 'HMW_HIDE_OLD_IMAGES', true );
Then go to WP Ghost > Change Paths > WP Core Security > Hide WordPress Common Paths. In the Hide File Extensions dropdown, select IMAGE Files. Click Save.

The image extensions that are blocked: jpeg, jpg, tiff, gif, bmp, png, and webp.
Verify by opening an incognito browser and trying to access an image at the old /wp-content/uploads/ path. It should return a 404.
Option 2: Redirect Old Image Paths (Recommended)
Instead of blocking old image URLs with a 404, you can redirect them to the new paths. This preserves external links and avoids duplicate content issues for SEO.
Go to WP Ghost > Change Paths > WP Core Security > Hide WordPress Common Paths. In the Hide File Extensions dropdown, select MEDIA Files (not IMAGE Files). Click Save.

With MEDIA Files selected, requests for images at the old /wp-content/uploads/ path redirect to the new custom path instead of returning a 404. External sites linking to your images continue working at the new address.
Troubleshooting
Images not loading in frontend after hiding old paths. Your theme or plugins may load images through CSS or JS files that still reference old paths. Enable Change Paths in Cached Files in WP Ghost > Tweaks so WP Ghost rewrites paths inside cached CSS and JS files. Also clear all caches after saving.
Google Images still shows old URLs. Google re-indexes images on its own schedule. Resubmit your sitemap in Google Search Console to speed up re-indexing. The transition does not affect rankings.
Frequently Asked Questions
What is the difference between hiding and redirecting?
Hiding (IMAGE Files) returns a 404 for old URLs — images do not load at the old address at all. Redirecting (MEDIA Files) sends old URLs to new ones so images still load at the new address. Use redirects when external sites link to your images. Use hiding when you want maximum security and old links do not matter.
Will hiding old image paths affect my image SEO?
Temporarily, yes. Images already indexed in Google Image Search will show 404 until Google re-indexes with new paths. Using redirects instead avoids this issue entirely. Resubmit your sitemap in Search Console to speed up re-indexing.
Do I need the wp-config.php constant for redirects too?
The HMW_HIDE_OLD_IMAGES constant is only needed for hiding (404 behavior). For redirects (MEDIA Files option), no wp-config.php edit is needed — just select MEDIA Files in the dropdown and save.
Does WP Ghost physically move my images?
No. Images stay in wp-content/uploads/. Both hiding and redirecting are handled through URL rewrite rules. Deactivating WP Ghost restores all original image paths instantly.
Related Tutorials
Change the Uploads Path – set the custom uploads path that old image paths redirect from.
Hide Paths in CSS Files – ensure images referenced in CSS also use new paths.
Hide Image Paths for Page Builders – fix builder-generated CSS cache files.
Customize All WordPress Paths – the complete path-changing guide.
Website Security Check – verify your configuration after changes.