title: Htaccess domain.com to www.domain.com works, but it loses other rules related to SEO
body: <p>EDIT: <strong>FIXED</strong></p>
  
  <p>Well, after stumbling around this site and Google for a few hours, I found the problem:</p>
  
  <p>Bad code:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
  RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
  </code></pre>
  
  <p><strong>Good code:</strong> </p>
  
  <pre><code>RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
  RewriteRule ^(.*)$ http://www.domain.com%{REQUEST_URI} [L,R=301]    
  </code></pre>
  
  <p>The REQUEST_URI seems to not work like $1... so I'm learning mod_rewrite the hard way. </p>
  
  <hr>
  
  <p>The question:</p>
  
  <p>Conditions:</p>
  
  <ul>
  <li><p>basic rewrite rules for SEO urls</p></li>
  <li><p>domain redirect from domain.com to www.domain.com</p></li>
  </ul>
  
  <p>Problem:</p>
  
  <p>The  non-www.domain.com pages lose their SEO-urls and turn back to the original php variables:</p>
  
  <p>Ex.  </p>
  
  <p>SEO-url: <strong>www.domain.com/Video+1234</strong></p>
  
  <p>NonWWW url:     <strong>domain.com/Video+1234</strong></p>
  
  <p>Result (browser address bar):</p>
  
  <p><strong>www.domain.com/index.php?video=1234</strong></p>
  
  <p>Desired:</p>
  
  <p><strong>www.domain.com/Video+1234</strong></p>
  
  <p>How can I make the server keep the old form?</p>
  
  <p><strong>.htaccess snippet:</strong></p>
  
  <pre><code>RewriteEngine On
  # RewriteBase /
  
  
  
  RewriteRule ^Video\-(.+)\+([0-9]+)$ index.php?video=$2
  
  
  RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
  RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
  </code></pre>