title: Javascript redirection based on url subdomain
body: <p>I'm going to write a script placed in the root of my server that will redirect users to the correct page based on the url subdomain, the pages to be reach are on another server but on the same ip, all the server had an httpd service in different port (eg. s1.example.com goes to 11.11.11.11:801) - That's cause are vmware esxi machine, and can't find another easy method to link my domain.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;script&gt;
  if (window.location.hostname == "s1.example.com") {
          window.location.replace("11.22.33.44:801");
  } else if (window.location.hostname == "s2.example.com") {
          window.location.replace("11.22.33.44:802");
  } else {
      document.write("&lt;center&gt;Sorry, incorrect server id&lt;/center&gt;");
  }
  &lt;/script&gt;
  &lt;body&gt;
  &lt;center&gt;Server Redirection in progress...&lt;/center&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>This redirect to <code>about:blank</code> and don't work. </p>
  
  <p>Can someone help? Thanks in advice.</p>