1

I am trying to rewrite/redirect a URL to another URL, but when it has a "#" in the arguments, this pulled through and shown in the new URL eg.

https://blah.co.uk/ep/doc/index.jsp#/download needs to be rewritten to https://blah.co.uk/Download/?Mode=doc

Now whatever I seem to try I always get the rewritten URL as https://blah.co.uk/Download/?Mode=doc#/download

it seems to always bring through the "#" and everything after it.

1 Answers1

0

This is because the hash part or URL (#/download in your case) is not requested from the web server at all, so nginx doesn't ever seen it and it can't be a subject of URL rewrites. You can see this question for more details. The hash part of URL is intended for client-side processing only, and the only way to get rid of it, AFAIK, is to use some client-side JavaScript, for example:

if (window.history.pushState) {
    window.history.pushState('', '/', window.location.pathname + window.location.search);
} else {
    window.location.hash = '';
}
Ivan Shatsky
  • 13,267
  • 2
  • 21
  • 37