Frage

I'm trying to do my SPA SEO-friendly and currently it has the links in the form #/path/page and i'm trying to move to #!/path/page sadly the site is currently in production and it has been shared already on socials, so i'm trying to keep available the old links (#/path/page).

Is there a way to redirect this traffic or any workaround to have both hash-prefix working, # and #!?

War es hilfreich?

Lösung

I found an easy solution, not involving AngularJS only javascript:

<script>
if (window.location.hash.indexOf("#/") != -1 &&  window.location.hash.indexOf("#!/") == -1 ){
    window.location.hash = window.location.hash.replace("#", "#!");
}
</script>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top