title: javascript how to switch pathname of window.location property and redirect
body: <p>I want to redirect a user from varying urls to a specific one.  I've tried various flavors of replacing and I cant seem to get the behavior I want.  This code works except I'm providing the hostname.  I want to use the existing hostname from windows.location.hostname and just provide a new pathname.  Sometimes the urls vary in size and slashes ('/').</p>
  
  <pre><code>window.location = 'http://localhost:36065/NewPath';
  </code></pre>
  
  <p>How would I change these urls? </p>
  
  <pre><code>http://somesite.com/xxx/yyy/zzz to http://somesite.com/NewPath
  http://somesite.com/xxx/yyy to http://somesite.com/NewPath
  http://somesite.com/xxx to http://somesite.com/NewPath
  </code></pre>
  
  <p>I think you get the point. The path can vary in paths, I want to replace everything after .com basically with 'NewPath'</p>
  
  <p>I'd like a clean regex solution if possible but I am quite the rookie in that dept. Thanks for any tips or tricks.</p>