title: RewriteRule for friendlier URLs
body: <p>I have a site that has a news section in a subfolder which I have been adding to manually.</p>
  
  <p><code>www.example.com/subfolder/news-and-views/name-of-article.php</code></p>
  
  <p>I recently made a rather simplistic CRUD feature to make adding these articles easier.</p>
  
  <p>I have:</p>
  
  <ol>
  <li><code>www.example.com/subfolder/news-and-views/index.php</code> - This displays all articles</li>
  <li><code>www.example.com/subfolder/news-and-views/article.php</code> - This takes an Id parameter from a <code>$_GET</code> request</li>
  </ol>
  
  <p>The url I end up with when I view an article is:</p>
  
  <p><code>www.example.com/subfolder/news-and-views/article.php?Id=name-of-article</code></p>
  
  <p>I did some reading and used <a href="http://htaccess.mwl.be/" rel="nofollow noreferrer">http://htaccess.mwl.be/</a> to test a RewriteRule</p>
  
  <p>The rule is: <code>RewriteRule /news-and-views/(.+) /news-and-views/article.php?Id=$1.php [L]</code></p>
  
  <p>However when I go to <code>news-and-vies/</code> (the index page) my CSS is stripped out and nothing is displayed as my paths are changed.</p>
  
  <p>Also it seems to go to article.phpid?= without passing anything, rather than just using the actual index page.</p>
  
  <p>To set paths I use a variable called <code>$path2root</code> which is the number of directories to the root.
  E.g <code>$path2root = "../../";</code></p>
  
  <p>So: I'd have <code>include $path2root . "includes/head.php"</code></p>
  
  <p>Is my RewriteRule interferring with this variable?</p>
  
  <p><strong>My .htaccess file</strong></p>
  
  <pre><code>RewriteEngine On
  RewriteRule /news-and-views/(.+) /news-and-views/article.php?Id=$1.php [L]
  </code></pre>
  
  <p><strong>My file structure</strong></p>
  
  <pre><code>/ .htaccess at this level (root)
  --/ subfolder
  ----/ news-and-views
  ------/ index of news and views
  </code></pre>