title: .htaccess variables and environment for modularity
body: <p>I inherited a very stuck-in-its-place website with no development environment. Among the LAMP stack, htaccess files has been my weakest point, and it appears the last developer did a lot of his work using htaccess files.</p>
  
  <p>I've tried tried modifiying it several times, but I only succeed in breaking it when trying to make a dev environment.</p>
  
  <p>What I'm trying to do is take every reference of my site </p>
  
  <pre><code>http://www.example.com/foo/bar
  </code></pre>
  
  <p>and change it to </p>
  
  <pre><code>[howeverVariablesWorkInHTACCESS]/foo/bar
  </code></pre>
  
  <p>being being built by some variable. I've seen references that htaccess can use variables, but I haven't seen any I really understand.</p>
  
  <p>Ideally, I wouldn't have to put in that variable value manually but somehow pull it from the file's location, but if that's not an option, altering just one line between servers would be much less of a headache than hundreds. </p>
  
  <p>So, TL;DR
  <strong>How to make variables in htaccess files and give them values based on file location?</strong></p>
  
  <p>And bonus request... suggested methods to really get a decent mastery of htaccess files? I haven't seen a fiddle equivilent for htaccess or clearly written guides as of yet.</p>