title: Javascript redirect loop
body: <p>I'm doing some old url redirection with javascript. </p>
  
  <p>My old urls in Google index are something like <code>domain.com/#!about/c3g8</code>. My new url for about us page is like <code>domain.com/#about</code> since I have change my site to one paged site.</p>
  
  <p>My old site has had 4 pages without including root page. Each page has had a unique ending. They are -</p>
  
  <pre><code>/c3g8
  /cjg9
  /cee5
  /cce3
  </code></pre>
  
  <p>The redirections cannot be done in .htaccess because they contain hash(#) character in them. Therefore, I have no choice but javascript. My current redirect js code is as follow</p>
  
  <pre><code>if(document.URL.indexOf(/!|\/c3g8|\/cjg9|\/cee5|\/cce3/)) {
      var url_new = document.URL.replace(/!|\/c3g8|\/cjg9|\/cee5|\/cce3/,'');
      window.location = url_new;
      break;
  }
  </code></pre>
  
  <p>All inner pages redirect properly but home page became a redirect loop and until I press <code>Esc</code> key twice.</p>
  
  <p>I have this <code>$('a[href^=#]').bind("click", function(event){....</code> code in my js too. How can I redirect without leading to a redirect loop?</p>
  
  <p>Thanks in advance!</p>