title: Using mod_rewrite to redirect .dev domains
body: <p>In the <a href="https://httpd.apache.org/docs/2.4/vhosts/mass.html" rel="nofollow noreferrer">Apache 2.4 docs on dynamic virtual hosts</a>, it says:</p>
  <blockquote>
  <h2>Mass virtual hosts with mod_rewrite</h2>
  <p>Mass virtual hosting may also be accomplished using mod_rewrite, either using simple RewriteRule directives, or using more complicated techniques such as storing the vhost definitions externally and accessing them via RewriteMap. These techniques are discussed in the rewrite documentation.</p>
  </blockquote>
  <p>I'm attempting to use mod_rewrite instead of mod_vhost_alias because I want it both ways: localhost/project and project.dev should point to the same folder, but either URL should work.</p>
  <p>Here's my latest attempt (currently in an .htaccess), which gets me a lovely 500 error.</p>
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} ^(.*)\.dev$ [NC]
  RewriteRule ^(.*)$ /%1/$1 [L,QSA]
  </code></pre>
  <p>If I do</p>
  <pre><code>...
  RewriteRule ^(.*)$ http://localhost/%1/$1 [L,QSA]
  </code></pre>
  <p>I can access the files, but the URL changes (not what I want). I've tried a variety of permutations with and without slashes, RewriteBase, etc.</p>
  <p>To be clear, I want <code>project.dev/index.php</code> and <code>localhost/project/index.php</code> to both be valid non-redirected references to <code>/var/www/html/project/index.php</code>. And I'd like to do this in a dynamic way, so I don't need to enter a new set of rules for every folder.</p>
  <p>I'm not fixated on doing this with .htaccess - virtualhosts are ok too as long as they're dynamic and I can still access my sites using the localhost/ scheme and the other machines on the network can connect to the sample sites in the usual way (192.168.1.22/project/index.php).</p>