if (window.location.hash !== "#search")
<p>Is there anything wrong with this syntax? This doesn't seem to work for me, even though if I alert the hash-tag and it matches with my if statement.</p>

<p>my code:</p>

<pre><code>if(window.location.hash) { 
   var thehash = window.location.hash;
   if (thehash !== "#search"){

      alert(thehash); // returns "#search"

      thehash = thehash.replace(/#/g, '/');
      window.location.replace("http://url.com/" + thehash + "/");
   }
}
</code></pre>

<p>Why does this still redirect urls containing #search</p>
