2

I want to take a url, add a prefix as well as remove the hashmark from the url. For example, redirect from http://localhost:8088/app1/#/hello to http://localhost:8088/apps/app1/hello.

I've tried this but it doesn't seem to work:

  location /app1/ {
    rewrite ^([^#]*)([#])\/(.*) /apps$1$3 permanent;
  }

It seems to have something to do with the hashmark. As I can go from http://localhost:8088/app1/q/hello to http://localhost:8088/apps/app1/hello with this:

  location /app1/ {
    rewrite ^([^q]*)([q])\/(.*) /apps$1$3 permanent;
  }

Is there something I need to do to handle the hashmark in a redirect?

1
10

You can't. The browser doesn't send anything after # to the nginx. The # indicates an URL fragment which is processed on a client only.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.