Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have image file URLs getting generated by Drupal CMS as: ...file.pdf?itok=xbXNF

I simply want to check till the .jpg part if it does not exist. If it does not exist then I want to do a 301 redirect to another page saying "Resource Deleted..".

I've tried doing it this way but it is resulting in a 500 Internal Server error:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^(.*[0-9]{10}j\.(jpg|jpeg|png|gif))?itok=.*$
  RewriteCond %1    ! -f
  RewriteRule ^.*$ /image-has-been-deleted.html [R=301,L]
share|improve this question
If the resource is deleted, you should return a 404 error if it might be found in the future, or 410 if it won't be available again. Also, is this a file: image-has-been-deleted? –  dan Sep 24 '13 at 5:25
It appears from this question that .html was missing from image-has-been-deleted? If so, perhaps you can update the question so it doesn't remain open. –  dan Sep 25 '13 at 7:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.