title: Apache2: Rewrite url to different port on localhost
body: <p>There is a service on my local computer available on <code>127.0.0.1:8080</code>, but I would prefer to use it rather like <code>127.0.0.1/qwerty/</code></p>
  
  <p>I tried to add in <em>/etc/apache2/sites-available/default</em>:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule (qwerty/.*)$ http://127.0.0.1:8080/$1 
  </code></pre>
  
  <p>Before that I symlinked rewrite.load in mods-enabled and restarted apache2 server.</p>
  
  <p>Unfortunately, it doesn't work.</p>
  
  <hr>
  
  <p><strong>Edit:</strong>
  To be more specific - This  service is calibre-server and its output is on port <code>8080</code>, while on port <code>80</code> works apache2. Then I'd like to do the same with my flask (python micro framework) project (it works on port <code>5000</code>).</p>
  
  <hr>
  
  <p><strong>Edit 2:</strong>
  I used reversed proxy trick from <a href="http://manual.calibre-ebook.com/server.html" rel="nofollow">link</a>, typing <code>calibre-server --url-prefix /calibre</code> in command line and it works (<s>without proxying anything</s> i needed to set proxy in  <em>/etc/apache2/sites-available/default</em>).</p>
  
  <p>What does not work is this flask thing. </p>
  
  <p>I will write down everything I did, because I'm not sure I understood correctly.
  @Ωmega : I do start flask project by typing <code>python demo.py</code> in demo directory.
  I created <code>.htaccess</code> file in this directory and put there the line you've suggested and it didn't work, so I changed all file content to:</p>
  
  <pre><code>Options FollowSymLinks
  RewriteEngine On
  RewriteRule ^$ http://127.0.0.1/flask/ [R=301,L]
  </code></pre>
  
  <p>but it still doesn't work.</p>