Redirect a URL with /#/

Our current website is built using AngularJS and as a result has URLs with /#/in them such as http://www.website.com/#/termsofuse

Short-sightedly, the URL for terms or use has been hard coded into a mobile application and although this has been changed, some users still have older versions.

Read More

We’re moving to a WordPress site (running on Azure) and the new URL for terms of use is http://www.website.com/termsofuse

The issue is that I want to redirect to the new URL if the old URL is used (from the app where it is hard coded in older versions) but I can’t find a way to do this with the /#/ in the URL (otherwise I could use HTML/JS at the old URL to redirect).

I have tried searching for solutions on Google and here but although I’m sure someone has had this problem, I’m finding it hard to define the search terms in order to get valuable results.

I also considered posting this on WordPress stackexchange but it is not really a WordPress question, I’m assuming I’ll need to use some other method.

Appreciate any ideas or advice. Thanks in advance.


So far I have learnt from responses that I probably need a JS solution and based on that I have found the below which looks similar (at least shows me how to isolate the fragment after the URL). Since my issue is very specific, and I only need to look for the specific fragment #/termsofuse could I use this code (with midifications) to look for that string and redirect based on that?

Checking URL fragment for a keyword

Related posts

2 comments

  1. Sadly, this is not possible as everything after the # doesn’t get sent to the server.

    What many people do in this sort of situation is to use a javascript/ajax solution to load the page.

  2. By your description, as your new web site is built on WordPress without AngularJs.

    So it hardly could approach your need in a traditional way. As hashtag # is a client symbol which is never passed on serve, so IIS on Azure will not get the portion after # of the URL, also URL rewrite module won’t see it too.

    So if possible to modify home page of your WordPress site, here is a workaround with using JavaScript get the portion after # of the URL and redirect to the right URL.
    Here is the code snippet:

    (function () {
    console.log(window.location.href);
    var url = window.location.href;
    params = url.split('#');
    console.log(params);
    if(params[1]){
    window.location.href = params[1];
    }
    })();

Comments are closed.