I'm doing an Ajax site and I must add to all urls "#!" house (does not work for external urls) from my site when a visitor clicks on the url.
For example when someone clicks on a url http://myajaxsite.com/contact/ ", the script changes the url like this:" http://myajaxsite.com/#!/contact / "

I have coded a little script jQuery but it does not work:

Code:
       <script>
            var  base_url = "http://localhost/ajaxsite/";
            function link(href) {
            
            // Check if the URL is an internal url
            if(href.indexOf(base_url) !=-1 || href.indexOf('http://') == -1 || href.indexOf('https://') == -1) {
            href = href.replace(base_url,'');
            return base_url + '#!/' + href;
             }
            }
             
            // Changes the link when someone clicks
            $(document).ready(function () {
            $('a').click(function() {
            $('a').attr('href', link(this));
            });
            });
            </script>

Can you help me?

Thank you