title: Redirect a subdomain to another domain's subfolder and keep the subdomain's URL
body: <p>I'd like to redirect a subdomain, say <a href="http://sub.domain.com" rel="nofollow">http://sub.domain.com</a> to another domain's subfolder like <a href="https://unrelatedsub.otherdomain.com/domain.com/" rel="nofollow">https://unrelatedsub.otherdomain.com/domain.com/</a> as well as everything inside, so that <a href="https://unrelatedsub.otherdomain.com/domain.com/u/r/l/file" rel="nofollow">https://unrelatedsub.otherdomain.com/domain.com/u/r/l/file</a> can be accessed by going to <a href="http://sub.domain.com/u/r/l/file" rel="nofollow">http://sub.domain.com/u/r/l/file</a></p>
  
  <p>Also, if it is possible, the browser's address bar should display the subdomain's url (<a href="http://sub.domain.com/u/r/l/file" rel="nofollow">http://sub.domain.com/u/r/l/file</a>)</p>
  
  <p>While searching for solutions, I came accross this possibility </p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
  RewriteRule ^(.*) https://unrelatedsub.otherdomain.com/domain.com/$1 [L,R]
  </code></pre>
  
  <p>However, in this case, accessing <a href="http://sub.domain.com/" rel="nofollow">http://sub.domain.com/</a> redirects to <a href="https://unrelatedsub.otherdomain.com/domain.com/sub/" rel="nofollow">https://unrelatedsub.otherdomain.com/domain.com/sub/</a> (sub shouldn't be in) and doesn't "hide" the URL.</p>