Question

A project I am working on is using pushState, but since Internet Explorer can't handle it correctly shebang is used in the changing of the URL. Is there away to set .htaccess to allow the shebang in the url but remove it and redirect it. As of now, if I were to goto http://www.mydomain.com/#!/whatever.php it just shows my index page. But what I would like it to do is if you goto http://www.mydomain.com/#!/whatever.php and redirect it to http://www.mydomain.com/whatever.php

Was it helpful?

Solution 2

Okay, so I figured out the answer to the question. So javascript is the only way to determine, so since using a shebang in the URL it will direct you to the index page of the domain, but still keeping the URL the same. So I just added to the top of my page the following.

$(document).ready(function(){
    var loc = self.document.location;
    if(loc.hash){
        var href = loc.hash.split("#!/");
        window.location = loc.protocol +'//'+ loc.host +'/'+href[1];
    }
});

OTHER TIPS

No, that is not possible using .htaccess, because everything after the # is not being sent to the server at all. You would have to use javascript to do the redirect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top