title: Redirecting to a relative URL in JavaScript
body: <p>My problem is that I want to redirect via JavaScript to a directory above.</p>
  <p><strong>My code:</strong></p>
  <pre><code>location.href = (location.href).substr(0, (location.href).lastIndexOf('folder'))
  </code></pre>
  <p>The URL looks like this:</p>
  <p><code>example.com/path/folder/index.php?file=abc&amp;test=123&amp;lol=cool</code></p>
  <p>The redirect affect just this:</p>
  <p><code>example.com/path/&amp;test=123&amp;lol=cool</code></p>
  <p>But want to have this:</p>
  <p><code>example.com/path/</code></p>
  <p>How can I do it?</p>