title: mod-rewrite recursive loop
body: <p>I want to change my website's dynamic urls to Search Engine Friendly URL's</p>
  
  <p>Now the urls like this www.website.com/news.php?id=127591 ,
  I want it became this www.website.com/news/127591/this-is-article-subject</p>
  
  <p>I added this</p>
  
  <pre><code>RewriteRule ^news/([0-9]+) /news.php?id=$1 [PT]
  </code></pre>
  
  <p>in my .htaccess file. Everything from /news.php?id=123 change to /new/123/this-is-article-subject</p>
  
  <p><strong>The problem is, now I have two links refer to the same contents. Both /news.php?id=123 and /new/123/this-is-article-subject are the exactly duplicate content</strong></p>
  
  <p>It is said that search engine will punish this if they found duplicated contents.</p>
  
  <p>I check the answers online and found this,</p>
  
  <pre><code>RewriteCond %{QUERY_STRING} ^id=([0-9]+) 
  RewriteRule ^news\.php /news/%1? [R=301,L]
  </code></pre>
  
  <p>HTTP 301 permanent redirect from the old URL to the new URL.</p>
  
  <p>But this still have problem. When I put those three lines together, it not works.</p>
  
  <pre><code>RewriteRule ^news/([0-9]+) /news.php?id=$1 [PT]
  RewriteCond %{QUERY_STRING} ^id=([0-9]+) 
  RewriteRule ^news\.php /news/%1? [R=301,L]
  </code></pre>
  
  <p><strong>I guess the reason is the recursive loop. How could I solve this kind of problem?</strong></p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>Update</p>
  
  <p>I changed to this</p>
  
  <pre><code>RewriteRule ^news/([0-9]+) /news.php?id=$1 [L]
  RewriteCond %{QUERY_STRING} ^id=([0-9]+) 
  RewriteRule ^news\.php /news/%1? [R=301,L]
  </code></pre>
  
  <p>None of the two url work.</p>