title: Why does .htaccess redirect URL routing fine but break css/js/image links after two levels deep?
body: <p>I have the following <strong>.htaccess</strong> file in a subdirectory of a site:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
  </code></pre>
  
  <p>I have the following <strong>index.php</strong> file:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;link href="css/main.css" rel="stylesheet"/&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
          &lt;script src="js/main.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;p&gt;if css loads, this should be green&lt;/p&gt;
          &lt;p id="message"&gt;javascript is NOT loaded&lt;/p&gt;
          &lt;div&gt;If images are displaying correctly, then there should be a green square below:&lt;/div&gt;
          &lt;img src="images/test.jpg"/&gt;
          &lt;div style="margin: 10px 0 0 0;font-weight: bold;background-color:#eee"&gt;&lt;?php echo '$_SERVER["REQUEST_URI"] = '. $_SERVER["REQUEST_URI"]; ?&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>All URLs are properly redirected to index.php. However, if the URL is more than one level deep below the sub-directory path, then my css/js/images paths are broken:</p>
  
  <p><img src="https://i.stack.imgur.com/z7zrs.jpg" alt="enter image description here"></p>
  
  <p><strong>What do I have to change to the .htaccess file so that routing works at any level and doesn't break my css/js/image paths?</strong></p>