【发布时间】:2013-03-16 17:12:26
【问题描述】:
我有一个像这样的文件目录的网站
/index.php (home page)
/storage (file storage directory)
/800 (800 pixel width dir)
/800x200.png
/800x350.png
....
/200 (200 pixel width dir)
/200x150.png
/200x185.png
...
....
/css
/style.css
/images
/logo.png
/jscript
/autoload.js
现在用户将发出请求http://example.com/images/200x150 或http://example.com/images/200x180。从两个 URL 我们知道第一张图片存在于/storage/200/200x150.png 但不存在第二张。
所以,我想为此写.htaccess(理论上是这里)。
Rewrite Condition /storage/{width}/{widthxheight}.png existed?
Rewrite Rule {output the image}
Rewrite Failed {go to /somedir/failed.php}
我该怎么做?
【问题讨论】:
-
RewriteCond path/to/file -f这是文件存在的简单规则... -
我确实建议 @Marshal 解释为不存在的文件创建不依赖于存在的规则...
标签: php apache .htaccess mod-rewrite url-rewriting