title: multiple mod_rewrite rules in .htaccess
body: <p>I am having difficulty getting several mod_rewrite rules to work together in my .htaccess files.  Throughout the enitre site I want to drop the "www." from all URLs.  I am using the following at the document root:</p>
  
  <pre><code>Options +FollowSymLinks
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^(.*)$ http://%1/$1 [R=301]
  </code></pre>
  
  <p>Then, in one folder "/help" I want to do 2 rewrites:</p>
  
  <ol>
  <li>change domain.com/help/1 <strong>to</strong> domain.com/index.php?question=1</li>
  <li>change domain.com/help/category/example <strong>to</strong> domain.com/index.php?category=example</li>
  </ol>
  
  <p>So in domain.com/help I have the following:</p>
  
  <pre><code>Options +FollowSymLinks
  RewriteRule ^([0-9]+)/?$ index.php?question=$1 [NC,L]
  RewriteRule ^category/([^/\.]+)/?$ index.php?category=$1 [NC,L]
  </code></pre>
  
  <p>The above 2 .htaccess files work for:<br>
  www.domain.com <strong>to</strong> domain.com<br>
  domain.com/help/1 <strong>to</strong> domain.com/index.php?question=1<br>
  domain.com/help/category/example <strong>to</strong> domain.com/index.php?category=example</p>
  
  <p>But, this does not work when I need to combine the 2 rewrites to both drop the "www." and to rewrite the subfolders to a url variable. e.g.:<br>
  www.domain.com/help/1 <strong>to</strong> domain.com/index.php?question=1<br>
  gives a 500 error.</p>
  
  <p>Where did I go wrong? And, is this best to do with 2 .htaccess files, or can/should the 2 files be combined into 1 .htaccess file at the document root?</p>