如何找不到文件,如何创建请求的图像文件? [关闭]

For example, if I have a file http://site.com/images/bird.jpg

When I go http://site.com/images/bird-200px-width.jpg the server will say "file not found".

When the server determines the file is not found, is there a way to check the /images/ directory to see if an image with the first part of the title ("bird.jpg"), and if it exists, automatically resize and generate an image with the requested filename instead of saying "file not found"?

Use mod_rewrite (specifically RedirectCond [twice]) to detect the absence of the thumbnail and rewrite to a script that generates and outputs the image.

Yes. As you asked a theoretical question, my answer will be theoretical too. Hope it's useful to you:

  1. You could check if the file does NOT exist with a rewrite cond in .htaccess (mod_rewrite)
  2. If the file doesn't exist, check again if the other file does exist (again a rewrite cond that looks for e.g. bird(.*).jpg where (.*) is your wildcard)
  3. Now if that file exists point to e.g. a php file that processes the image and shows it.