我是Apache mod重写的新手。 我想达到的是这个。
如果一个图片(gif,jpg,png)被请求从一个url,并没有在那里find,它应该会自动尝试从另一个目录提供这个图像。
尝试这个:
RewriteEngine on # if there's no file at the requested path.. RewriteCond %{REQUEST_FILENAME} !-f # then, if it's an image file, try the other path: RewriteRule /([^/]*\.(gif|png|jpg))$ /images/path/$1
这将对这些规则适用的每个映像文件请求起作用; 限制只是一个特定的“原始”目录,然后根据需要进行调整:
RewriteRule ^/old/images/path/([^/]*\.(gif|png|jpg))$ /images/path/$1
如果你把这个在.htaccess或改变RewriteBase ,相应地改变。