Dear folks, Attempting to rewrite images having a rewrite rule which should only fire when two conditions exist: image begins with IMG or even better IMG- and next the file should exist.

Nice url: IMG-folder/file.jpg fetched ugly url image under water.

The code below works when no the weather is set, in addition to when just the second !-f condition is placed, although not when both rules exist together. Why? Ideas/code/surveys are very appreciated. Thanks

Q1. Im a little confused: may be the first condition really necessary? Since I am stating to simply rewrite IMG-.... files towards the ugly web addresses under water.

Q2. How come this code below fail then both the weather is fired?

RewriteCond %{REQUEST_URI} ^IMG.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^IMG-(.+)_w(.+)_h(.+).jpg$ imgcpu\.php\?src=$1\.jpg&w=$2&h=$3 [L]

%{REQUEST_URI}, always consists of the entire asked for path. The very first argument of RewriteRule however is relative. Should you match a %{REQUEST_URI} against a pattern that identifies the beginning position, ^, it's also wise to range from the leading slash.

RewriteCond %{REQUEST_URI} ^/IMG.*$

I am also slightly unclear about the type of the virtual Web addresses. Does IMG occur two times inside a typical image URL? Is /IMG-folder/IMG-12_w34_h56.jpg a legitimate virtual filename?