1

I have this line of .htaccess This line is used to get images from another server.

RewriteRule ^resources/fabricantes(.*)$ http://mysecondserver.com/arq/pictures/fab$1

than, if I have the url: http://myserver.com/resources/fabricantes/fab_1.jpg this image will be get from: http://mysecondserver.com/arq/pictures/fab/fab_1.jpg

The Problem: In some cases, the image doesn't exists on mysecondserver.com, how can I redirect to a "image unavailable" image in this cases?

Andy Schmitt
  • 441
  • 1
  • 6
  • 23

2 Answers2

1

First think you need to understand that this rule can only work from mysecondserver.com host not from server.com.

On mysecondserver.com place this .htaccess in /arq/pictures/.htaccess:

RewriteEngine On
RewriteBase /arq/pictures/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ no-image.jpg [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

On mysecondserver.com, you would have .htaccess checking for -f status of the REQUEST_FILENAME. It could send the user back to the first server, if necessary. The alternative is to explicitly list all known failures back on your first server, which is a lot of work for you (even if you have a complete list). There's no way for the first server to know if a file actually exists on the second server.

Phil Perry
  • 2,126
  • 14
  • 18