# Return default placeholder image when image file on server not found

**URL:** <https://www.ruby-forum.com/t/return-default-placeholder-image-when-image-file-on-server-not-found/244695>\
**Category:** NGINX\
**Created:** [May 28, 2016, 9:33pm UTC](https://www.ruby-forum.com/t/return-default-placeholder-image-when-image-file-on-server-not-found/244695 "2016-05-28T21:33:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [May 28, 2016, 9:33pm UTC](https://www.ruby-forum.com/t/return-default-placeholder-image-when-image-file-on-server-not-found/244695/1 "2016-05-28T21:33:16Z")

</div>

What is the right way to convert this from .htaccess to nginx.conf…

##Return default placeholder image when image file on server not found  
RewriteCond %{DOCUMENT\_ROOT}%{REQUEST\_URI} !-f  
RewriteRule .(gif|jpe?g|png) /image404.php [NC,L]

Posted at Nginx Forum:

> **[Return default placeholder image when image file on server not found](https://forum.nginx.org/read.php?2,267211,267211#msg-267211)**
>
> What is the right way to convert this from .htaccess to nginx.conf.. ##Return default placeholder image when image file on server not found RewriteCond %{DOCUMENT\_ROOT}%{REQUEST\_URI} !-f RewriteRule \\.(gif|jpe?g|png) /image404.php \[NC,L\]

---

<div class="post-metadata">

**Author:** ![JoakimR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e68b1a/32.png) [@JoakimR](https://www.ruby-forum.com/u/JoakimR)\
**Post date:** [May 29, 2016, 9:41am UTC](https://www.ruby-forum.com/t/return-default-placeholder-image-when-image-file-on-server-not-found/244695/2 "2016-05-29T09:41:07Z")

</div>

Found the answer on IRC #Freenode #nginx by catbeard

location ~ .(png|jp?g|gif)$ {  
error\_page 404 /404.png;  
}

> <https://serverfault.com/questions/481600/nginx-display-a-not-found-image/481612#481612>

Posted at Nginx Forum:

> **[Re: Return default placeholder image when image file on server not found](https://forum.nginx.org/read.php?2,267211,267213#msg-267213)**
>
> What is the right way to convert this from .htaccess to nginx.conf.. ##Return default placeholder image when image file on server not found RewriteCond %{DOCUMENT\_ROOT}%{REQUEST\_URI} !-f RewriteRule \\.(gif|jpe?g|png) /image404.php \[NC,L\]
