title: Apache .htaccess relative request URI redirection
body: <p>First of all, I have following directory structure:</p>
  
  <ul>
  <li>/project_directory/rewriting_experimentation_directory
  <ul>
  <li>htaccess File</li>
  <li>realfile.txt</li>
  </ul></li>
  </ul>
  
  <p>What I am trying to do is following:</p>
  
  <p>When the user requests <code>http://domain.xts/.../rewriting_experimentation_directory/falsename</code>,
  realfile.txt should be displayed. That I have already achieved, with the following expression in the .htaccess file:</p>
  
  <pre><code>RewriteEngine On
  RewriteRule   ^falsename$  realfile.txt
  </code></pre>
  
  <p>However, I am also trying to achieve that when the user <strong>requests</strong> this url <code>http://domain.xts/.../rewriting_experimentation_directory/realfile.txt</code>,
  that he be redirected to <code>http://domain.xts/.../rewriting_experimentation_directory/falsename</code> and then, naturally, be displayed the content fo realfile.txt.</p>
  
  <p>I have encountered two issues, however:</p>
  
  <ol>
  <li>Firstly, Redirect 301, RedirectMatch, Alias etc. all require
  absolute pathes, and not those relative to the directory the
  .htaccessfile is in. This is completely inacceptable, since the
  path before the directory <code>rewriting_experimentation_directory</code> differs from that on localhost when I upload it to domain.xts (or anywhere else)</li>
  <li>Secondly, it does not match the <strong>requested</strong> URL, but the URL that I shall henceforth refer to as the "<strong>response</strong>" URL, namely the name of the file whose content Apache is returning to the client. Thus, if I try to redirect from realfile.txt to falsename, I get an infinite loop. (Which takes a bit long to load, sadly).</li>
  </ol>
  
  <p>Is there any way to achieve this?</p>
  
  <p>Also, as an answer to the question, 'Why would you need that?' – to learn, for once, and secondly, for future reference (which may still count as learning). I hope that does not invalidate my question.</p>