wordpress/htaccess - set default image for any missing one

I've had a heck of a time with this.

I want to set up a default image to take the place of any missing one (in the uploads folder, or sitewide even) on my wordpress site.

I thought perhaps I could set up something like this in an htaccess file in my uploads folder:
------------------

ErrorDocument 404 /default.jpg

---------------------

That had no effect, I still get a broken image image on webpages with missing images and if I go to the url of the image, I get the standard 404 page.

Also tried:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} \.(jpg|png)$ [NC]
RewriteRule .* /default.jpg     #and a variety of paths in case that was the problem.

and a number of other things, none worked.

I went to my top level directory's htaccess and entered this, which looked impressive:

<FilesMatch "\.(gif|jpe?g|png|ico)$">
ErrorDocument 403 http://www.(mysite.com)/wp-content/uploads/default-gen1-165x165.png
ErrorDocument 404 http://www.(mysite.com)/wp-content/uploads/default-gen1-165x165.png
ErrorDocument 500 http://www.(mysite.com)/wp-content/uploads/default-gen1-165x165.png
</FilesMatch>

But it didn't work.

Here's what I currently have in my top level .htaccess file:

-------------------------------------------------------

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#change 'alerts' to 'news'
RewriteRule ^section/alerts(.*)$ section/news$1 [R=301,L]
RewriteRule ^section/sales(.*)$ section/shopping$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#change 'alerts' to 'news'
RewriteRule ^section/alerts/(.*)$ section/news/$1 [R=301,L]

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

--------------------------------------------

I've been working on this problem for hours and am fit to be tied!

Would appreciate some help!

Chris
St_Aug_Beach_BumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Edwin HofferTechnical ExpertCommented:
Hello,

Use this code in your .htaccess file:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ not-found.gif [NC,L]

Open in new window


Change not-found.gif to your image

Thanks
Edwin
0
St_Aug_Beach_BumAuthor Commented:
Hi Edwin,

I put that in the .htaccess of my uploads folder, doesn't work though, goes to the server's default not found page,

Chris
0
Edwin HofferTechnical ExpertCommented:
If the above code is not working then download and install: WP 404 Images Fix plugin https://wordpress.org/plugins/wp-404-images-fix/

and Put an alternative image for 404 not found images:

alternative image
0
St_Aug_Beach_BumAuthor Commented:
HI Edwin,

Man, this is a stubborn problem. I installed/activated the plugin and have tried both 'hide' and 'alternative' options with them having no effect at all. I'm using wp 3.9.1,

Chris
0
Edwin HofferTechnical ExpertCommented:
Both are working fine for me, I am using WordPress 3.9.2.

Add full URL in alternative image and check. Instead of refreshing the page use Ctrl+F5 for hard refresh and check again.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.