title: Redirect to the same path in a different domain
body: <p>How can I redirect all <a href="https://www.A.net/Page.html" rel="nofollow noreferrer">https://www.A.net/Page.html</a> requests for some page Page.html to the corresponding page on another domain <a href="https://www.B.net/Page.html" rel="nofollow noreferrer">https://www.B.net/Page.html</a> via the <a href="https://www.A.net/404.html" rel="nofollow noreferrer">https://www.A.net/404.html</a>? Github/Gitlab Pages redirect all Page-not-found errors to the latter. Is it possible to somehow retrieve the original requested page and use this in a Javascript function to modify the redirection URL?</p>
  
  <p>I currently use something like the following HTML code for a many-to-one redirection, but I rather need a one-to-one redirection (i.e. not always to the same <a href="https://www.B.net/404.html" rel="nofollow noreferrer">https://www.B.net/404.html</a>).</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"/&gt;
          &lt;meta http-equiv="refresh" content="0; URL=https://www.B.net/404.html"&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/&gt;
          &lt;meta name="viewport" content="width=device-width; initial-scale=1.0"/&gt;
      &lt;/head&gt;
      &lt;body&gt;
          You are being redirected to https://www.B.net/404.html &lt;a href="https://www.B.net/404.html"&gt;https://www.B.net/404.html&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Current situation</strong> (many-to-one):</p>
  
  <pre><code>www.A.net/Page1.html -&gt; www.A.net/404.html -&gt; www.B.net/404.html
  www.A.net/Page2.html -&gt; www.A.net/404.html -&gt; www.B.net/404.html
  </code></pre>
  
  <p><strong>Desired situation</strong> (one-to-one):</p>
  
  <pre><code>www.A.net/Page1.html -&gt; www.A.net/404.html -&gt; www.B.net/Page1.html
  www.A.net/Page2.html -&gt; www.A.net/404.html -&gt; www.B.net/Page2.html
  </code></pre>
  
  <p><strong>Note</strong> that I host static websites at Github/Gitlab.</p>
  
  <p><strong>Specific context</strong>: I want to redirect my Gitlab and Bitbucket Pages to my Github Pages.</p>