title: Angular - rewrite for ErrorDocument add old path to new path uri after redirect
body: <h2>Summary</h2>
  <p>I have a weird interaction in my apache config when i try to trigger my <strong>503</strong> ErrorDocument, the first path is added to the second ui path after my RewriteRule does the redirect.</p>
  <p>I have a lot of micro-services wrote in Angular 12, so to simplify and explain my problem i will simplify my conf with an example, one is an app that need to trigger the maintenance page and the other one is the maintenance app that use angular route parameters.</p>
  <h2>Conf</h2>
  <p>Here is the apache httpd.conf for the two :</p>
  <pre><code>&lt;Directory &quot;/opt/apache/www/html/old-ui&quot;&gt;
       &lt;IfModule mod_rewrite.c&gt;
           RewriteEngine On
           ErrorDocument 503 /maintenance-ui/old
           RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
           RewriteRule ^.*$ - [R=503]
           # RewriteRule ^.*$ /maintenance-ui/old [L,NC,R=503] # also tried that
  
           RewriteCond %{REQUEST_FILENAME} -f [OR]
           RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
           RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
  
           RewriteRule ^ - [L]
           RewriteRule ^ \index.html
       &lt;/IfModule&gt;
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require all granted
  &lt;/Directory&gt;
  
  </code></pre>
  <pre><code>&lt;Directory &quot;/opt/apache/www/html/maintenance-ui&quot;&gt;
       &lt;IfModule mod_rewrite.c&gt;
           RewriteEngine On
           RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
           RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
  
           RewriteRule ^ - [L]
          RewriteRule ^ index.html
  
       &lt;/IfModule&gt;
  
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require all granted
  &lt;/Directory&gt;
  </code></pre>
  <pre><code>const routes: Routes = [
    { path: '', component: MaintenanceComponent },
    { path: ':nameService', component: MaintenanceComponent }
  ];
  </code></pre>
  <h2>Result</h2>
  <p>My problem is that when i enter <a href="https://my-web-site/old-ui/" rel="nofollow noreferrer">https://my-web-site/old-ui/</a> in my browser instead of being redirected to :</p>
  <ul>
  <li><a href="https://my-web-site/maintenance-ui/old" rel="nofollow noreferrer">https://my-web-site/maintenance-ui/old</a></li>
  </ul>
  <p>I end up with :</p>
  <ul>
  <li><a href="https://my-web-site/maintenance-ui/old-ui" rel="nofollow noreferrer">https://my-web-site/maintenance-ui/old-ui</a> (it's like apache added the old path as an uri)</li>
  </ul>
  <p>And apache logs seems to say that i sent the right thing:</p>
  <p><code>[perdir /opt/apache/www/html/maintenance-ui/] strip per-dir prefix: /opt/apache/www/html/maintenance-ui/old-&gt; old</code></p>
  <p>(log file) : <a href="https://drive.google.com/file/d/1LFtAppgIsVCXmeB-Ku9hyTgIgWPeitHs/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1LFtAppgIsVCXmeB-Ku9hyTgIgWPeitHs/view?usp=sharing</a></p>
  <p>So what's the problem here ?</p>
  <p><em><strong>P.S :</strong></em> I need to use route parameter to dynamically change what I need to show to the user depending of what app they came from.</p>
  <p><em><strong>P.S 2 :</strong></em> I could do a <code>.split('-')</code> in angular to remove the <strong>-ui</strong>, but i find it dirty when my conf apache seems ok.</p>