title: Excluding images from mod_rewrite rule
body: <p>Inadvertently my htaccess script is changing image URLs so that any image with "portfolio/" in its URL path is adversely affected.</p>
  
  <p>Is there any way to exclude images from that particular rule?</p>
  
  <pre><code>redirect 301 "/sitemap.xml" http://www.example.com/sitemap.php
  
  RewriteEngine On
  
  RewriteCond %{REQUEST_URI} !portfolio/project
  RewriteCond %{REQUEST_URI} /.*portfolio/.*$ [NC]
  RewriteRule ^(.*)portfolio(.*)$ /$1portfolio/project$2 [R=301,L]
  
  RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/sitemap.php
  RewriteRule ^(.*)$ /index.php/$1 [L]
  </code></pre>