Change HTTP response status code 200 – 206

apache-2.2

I was trying to redirect the users to see a default image instead of a missing image. In addition to this, I wanted to try if I could change 200 HTTP response status code to 206 and still show the default image.
I tried RewriteRule with [R=206,L] but it's showing an HTML document pertaining to 206 response.

Is this possible?

Best Answer

Yes to the first one, no to the second one. A 206 response can only be sent when partial content is being sent in response to a Range request. I'm wondering why you'd want to do this?

Anyway, the image thing is doable - put this in a <Directory> block for your docroot.

RewriteEngine On
RewriteCond %{REQUEST_URI} \.(jpg|gif|png)$ [NC] # Add any other image filetypes you need
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ default_image.jpg [L]
Related Topic