title: Apache mod_rewrite works in .htaccess but not httpd.conf
body: <p>I'm experimenting with mod_rewrite for the first time (I'm a web newbie, but trying to learn).  I'm trying to get <strong>bob.html</strong> to redirect to <strong>alice.html</strong>  (read: URL stays the same, page content is <strong>alice.html</strong>).  Both files are in <strong>/var/www/</strong>.  I'm running Ubuntu 10.10 w/Apache 2.2.16.</p>
  
  <p>Here's what works in the <strong>.htaccess</strong> file placed in the <strong>/var/www/</strong> directory:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine on
  RewriteRule ^bob.html$ alice.html
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>This behaves as expected, but it does not work when moved to the httpd.conf file (just learning best practices w/performance and such).  I read somewhere that when using mod_rewrite in <strong>httpd.conf</strong> file, leading slashes are required, so my <strong>httpd.conf</strong> file looks like:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine on
  RewriteRule ^/bob.html$ /alice.html
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>I also read that <strong>/etc/apache2/sites-enabled/000-default</strong> needs to have <strong>AllowOverride</strong> set to <strong>All</strong>.</p>
  
  <pre><code>&lt;Directory /var/www&gt; 
  ...
  AllowOverride All
  ...
  &lt;/Directory&gt;
  </code></pre>
  
  <p>I <em>think</em> that's just for use with <strong>.htaccess</strong> but I wasn't sure so I just left it in.</p>
  
  <p>With all of these configuration settings, the redirection does not work.  I've tested to make sure the file itself is being read (someone suggested <strong>httpd.conf</strong> isn't used anymore and <strong>apache2.conf</strong> is used instead) by inserting erroneous code.  I've taken a look at a couple other questions/answers but I still cant figure it out.</p>
  
  <p><em>Edit</em>: It should be noted that I'm using <strong>/etc/init.d/apache2 restart</strong> after each change to <strong>httpd.conf</strong> to restart Apache and (hopefully) reload the configuration.</p>