I am using ajax to load content for my site. When I dynamically load a page http//www.example.com/a/b/c I change my current page's url to http//www.example.com/xyz/#!/a/b/c by setting it through javascript using window.location
Now what I want to do is that when somebody enters a url http//www.example.com/xyz/#!/a/b/c in the browser, he should be directed to http//www.example.com/a/b/c instead of http//www.example.com/xyz/
This is similar to what is used on facebook http//www.facebook.com/?ref=logo#!/reqs.php#friend automatically takes me to http//www.facebook.com/reqs.php#friend when loaded without ajax.
I tried using javascript to implement this
requestedURL = ""+window.location+"";
position = requestedURL.search("#!");
domainame = "http://localhost"
if(position != -1){
newpage = requestedURL.substr(position+2);
requestedURL = "";
window.location = domainame+newpage;
}
This did work me but now every time when I load a page even through ajax, this script gets executed.
Can someone help me out with this. A solution through .htaccess would also do for me.