Adding to htaccess file for missing images
-
I have a very large WP site and for reasons I won’t bore you with I have to delete a load of photos on the site but I don’t want the site to look broken so I want to have any missing images replaced with a default image instead.
I have done this successfully with another non-WP site using this code in the htaccess file:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ RewriteRule .* missing.jpg [L]
However when I have added that to the existing htaccess file on the WP site it doesn’t work, and fiddling has resulted in all sorts of errors from totally breaking the site to it replacing EVERY image on the site not just the broken ones!
So if the following is the WP htaccess file code – what can I add to make the code above work?
SetEnv PHPRC "/home/swinger1/public_html" <IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
- The topic ‘Adding to htaccess file for missing images’ is closed to new replies.