Reputation:
There is a 404 redirect, working fine, but I'm looking for a solution in the .htaccess file to make an exception in case of images (jpg, gif, png, ...) not found.
Someone here with a possibility to do so?
Actual rule in the htaccess file:
ErrorDocument 404 http://example.com/
Best regards!
Upvotes: 0
Views: 2450
Reputation: 3918
I am guessing that if an image is not found you want the user to see an image that has an error message instead of the default text page that is normally displayed. Here is how to do that:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Add additional file extensions to the list as needed.
RewriteCond %{REQUEST_FILENAME} \.(gif|jpg|jpeg|bmp|tiff)$
RewriteRule (.*) /relative/location/of/errorimage.jpg
If there is something else you are trying to do, comment back and I'll adjust the example accordingly.
Upvotes: 2