[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Show default image if requested one has not been found on server - htaccess level

Posted on 2011-10-04
Medium Priority
Last Modified: 2012-05-12

I have a image hosting website, I do obviously allow hotlinking, my problem is that sometimes I need to remove some images for copyright infringement, etc. and this image has been already embed on some other websites, forums, etc. In this case instead of request image X square currently shows up. I need some htaccess level solution to show some default image in case if the requested one does not exist anymore.

Thanks for help
Question by:jhmplondon
1 Comment
LVL 16

Accepted Solution

sjklein42 earned 2000 total points
ID: 36911580
Use the ErrorDocument (404) directive.


If you want to limit the redirect to only those files that were blocked, you can use the <files> directive:


<Files "originalimage.jpg">
ErrorDocument 404 /errors/notfound.jpg

Open in new window


Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question