RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(photos/.*\.jpg)$ watermark.php?filename=$1 [L]