title: .htaccess rewrites causing whitescreen of death
body: <p>I've been battling some .htaccess rewrite issues lately for a webserver I provide with code provided to me externally by a consulting company. I've been chasing this issue from the perspective of 'rewrites do not work' however I think I've discovered that the actual problem is that rewrites are causing a white screen of death. </p>
  
  <p>My site </p>
  
  <pre><code>http://it-news.awesome.net/news/it/153/coverstory/
  </code></pre>
  
  <p>my .htaccess</p>
  
  <pre><code>RewriteRule ^news/(.*)/(.*)/(.*)/$ news.php?department=$1&amp;newsid=$2&amp;newstitle=$3 [NE,L]
  RewriteRule ^news/(.*)/(.*)/$ news.php?department=$1&amp;archive=$2 [NE,L]
  RewriteRule ^news/(.*)/$ news.php?department=$1&amp;archive=0 [NE,L]
  </code></pre>
  
  <p>will produce the output URL</p>
  
  <pre><code>http://it-news.awesome.net/news.php?department=it&amp;newsid=153&amp;newstitle=coverstory
  </code></pre>
  
  <p>which is perfect. I can copy paste this from the rewrite tester tool here</p>
  
  <p><a href="http://htaccess.mwl.be/" rel="nofollow">http://htaccess.mwl.be/</a></p>
  
  <p>into my browser and the articles open fine. Going to the main page and browsing the site (which has pretty URLS turned off currently) will have all these pages displaying and everything is OK. </p>
  
  <p>The minute I try and use the </p>
  
  <pre><code>http://it-news.awesome.net/news/it/153/coverstory/
  </code></pre>
  
  <p>link, I'm hit with a white screen of death. I've stepped through the .htaccess file and commented out individually the matching lines and once there is no match, then I'm taken to my homepage and can browse normally. </p>
  
  <p>I've further tested this by creating a test.php with the code</p>
  
  <pre><code>&lt;?php     
  echo $_GET['var'].' "this is static text" '.$_GET['var2'];
  ?&gt;
  </code></pre>
  
  <p>and creating a rewrite rule </p>
  
  <pre><code>RewriteRule ^(.*)/(.*)$ test.php?var=$1&amp;var2=$2 [NC,L]
  </code></pre>
  
  <p>and this DOES work. </p>
  
  <pre><code>http://it-news.awesome.net/testvariable1/testvariable2/
  </code></pre>
  
  <p>outputs </p>
  
  <pre><code>testvariable1 "this is static text" testvariable2
  </code></pre>
  
  <p>as a webpage. 
  I'm forced to conclude that </p>
  
  <ol>
  <li>my webserver rewrites work correctly</li>
  <li>php interprets the variables given from rewrites OK in SOME situations </li>
  </ol>
  
  <p>but now I'm hopelessly stuck. I don't know where to begin testing or debugging php and I can't imagine why some php is going to fall down and whitescreen when it seems to be correctly interpreting variables from a rewrite and can open those pages OK without using rewrites. </p>
  
  <p>Anyone come across this? I wonder if it's some PHP server config or something that I've missed. </p>
  
  <hr>
  
  <p>update after the comments from Mike Rocket</p>
  
  <p>further testing gets me to the following .htaccess. the top 4 lines referencing test.php are for testing only and the bottom 3 are the real hopefully working documents. </p>
  
  <pre><code>RewriteBase /
  RewriteEngine On
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule ^ - [L]
  RewriteRule ^hello\.html$ redir.html
  RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
  RewriteRule ^(wordpress|user)($|/) - [L]
  RewriteRule ^(mysqladmin|user)($|/) - [L]
  RewriteRule ^(admin|user)($|/) - [L]
  
  RewriteRule ^(.*)/(.*)/(.*)/(.*)$ test.php?t1=$1&amp;t2=$2&amp;t3=$3&amp;t4=$4 [NE,NC,L]
  RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ test.php?t1=$1&amp;t2=$2&amp;t3=$3&amp;t4=$4 [NE,NC,L]
  RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)$ test.php?t1=$1&amp;t2=$2&amp;t3=$3&amp;t4=$4 [NE,NC,L]
  RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ test.php?t1=$1&amp;t2=$2&amp;t3=$3&amp;t4=$4 [NE,NC,L]
  
  
  RewriteRule ^news/(.*)/(.*)/(.*)/$ news.php?department=$1&amp;newsid=$2&amp;newstitle=$3 [NE,L]
  RewriteRule ^news/(.*)/(.*)/$ news.php?department=$1&amp;archive=$2 [L]
  RewriteRule ^news/(.*)/$ news.php?department=$1&amp;archive=0 [L]
  </code></pre>
  
  <p>my new test.php contains </p>
  
  <pre><code>&lt;?php
  
  echo 't1: '.$_GET['t1'].'&lt;br/&gt;';
  echo 't2: '.$_GET['t2'].'&lt;br/&gt;';
  echo 't3: '.$_GET['t3'].'&lt;br/&gt;';
  echo 't4: '.$_GET['t4'].'&lt;br/&gt;';
  
  ?&gt;
  </code></pre>
  
  <p>what I'm seeing is that for the test.php lines 
  using 
  <a href="http://testsite.website.com/test/test2/test3/test4/" rel="nofollow">http://testsite.website.com/test/test2/test3/test4/</a></p>
  
  <p>is that the first 2 will produce broken output like this </p>
  
  <pre><code>t1: test.php/test2
  t2: test3
  t3: test4
  t4: 
  </code></pre>
  
  <p>and hashing out the top 2 lines, the second 2 lines in the test.php relevant section will give me the output I want. </p>
  
  <pre><code>t1: test.php
  t2: test2
  t3: test3
  t4: test4
  </code></pre>
  
  <p>what I'm finding horrible here, is that my first variable 'test' coincidently has the same name as my php file itself and if that is the case, it's giving through the name of the php file as a variable instead of the word test.</p>
  
  <p>this </p>
  
  <p><a href="http://testsite.website.com/" rel="nofollow">http://testsite.website.com/</a><strong>test</strong>/test2/test3/test4/
  produces  </p>
  
  <pre><code>t1: test.php
  t2: test2
  t3: test3
  t4: test4
  </code></pre>
  
  <p>but this </p>
  
  <p><a href="http://testsite.website.com/" rel="nofollow">http://testsite.website.com/</a><strong>test1</strong>/test2/test3/test4/</p>
  
  <p>produces this</p>
  
  <pre><code>t1: test1
  t2: test2
  t3: test3
  t4: test4
  </code></pre>
  
  <p>and I have a feeling this is the root of my issue. In my live situation I have </p>
  
  <p>my.website.com/news/it</p>
  
  <p>calling a news.php file as well. So it's passing in 'news.php' instead of 'news' everytime. I feel like this isn't normal and I should be able to stop this from happening somehow... </p>