title: Basic URL rewriting: How to have a css link, img src, etc, ignore it?
body: <p>I have a website running at <code>localhost/pm</code> and the RewriteBase is correctly set to <code>/pm/</code>. There is a link tag in my document: <code>&lt;link ... href="themes/default/css/default.css"&gt;</code>.</p>
  
  <p>When the url is <code>localhost/pm</code> or <code>localhost/pm/foo</code> the CSS works all right. When there are more slashes in the URL, however, like <code>localhost/pm/foo/bar</code> the relative URL if the stylesheet changes to <code>foo/themes/default/css/default.css</code>. </p>
  
  <p>How do I get this to work without having to put some sort of PHP path resolution in the link tag?</p>
  
  <pre><code># invoke rewrite engine
  RewriteEngine On
  RewriteBase /pm/
  
  # Protect application and system files from being viewed
  RewriteRule ^(?:system)\b.* index.php/$0 [L]
  
  # Allow any files or directories that exist to be displayed directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # Rewrite all other URLs to index.php/URL
  RewriteRule .* index.php/$0 [PT]
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Basically what I need now is this:
  If request contains folder name <code>/themes/</code> scrap everything that is before <code>/themes/</code> and rewrite the rest to <code>/pm/themes/...</code></p>
  
  <p>I tried it like this: <code>RewriteRule ^.*(/themes/.*)$ /pm/themes/$1</code> but I get an internal server error. Why?</p>
  
  <p>If I do it like this: <code>RewriteRule ^.*(/themes/.*)$ /pm/themes/</code> (ie. just remove $1 from the end) and use the URL <code>http://localhost/pm/foo/themes/foo/</code> the resulting physical location is <code>http://localhost/pm/themes</code> which is what is expected too, which in turn means that at least my regex is correct. What am I missing?</p>