 <blockquote> <p>Not sure why it acts like that tho.. The CSS folder is in the same folder as the actual php file.</p> </blockquote> <p>You've linked to it using a relative URI:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" media="all" href="./css/text.css" /&gt; </code></pre> <p>e.g. the <code>./css/text.css</code>, and while the css file may be in the same directory as <code>picture.php</code> file (which I assume is what is generating the content) but the browser is what actually makes the request for the CSS, not the picture.php script. The browser requests this URL <code>http://www.mysite.com/picture/1</code>, and the server internally rewrite the <code>/picture/1</code> to <code>/picture.php?id=1</code>, the browser has no clue that's happened. So it sees the base URI as <code>/picture/</code>. If the browser went directly to the php file: <code>http://www.mysite.com/picture.php?id=1</code>, the base URI would be <code>/</code> and the css would resolve just fine to <code>/./css/text.css</code>. But the <code>/picture/1</code> request has a different base URI so the browser (with no clue that the base is different) blindly attempts to retrieve the css as <code>/picture/./css/text.css</code>, which fails because you have rules that mishandle that URI. Normally you'd just get a 404, but the rules you have after the picture rewrite mishandles the URI and returns a 500 server error.</p> <p>You can either add in your header:</p> <pre><code>&lt;base href="/"&gt; </code></pre> <p>in the content generated by <code>picture.php</code>, or make the URI's absolute:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" media="all" href="/css/text.css" /&gt; </code></pre>