0

I'm struggling to find out how to perform the following redirection via .htaccess and it's driving me a bit crazy.

Scenario:

If requests points to one of the following paths, do not perform any redirection:

  • /
  • /#/
  • /#/admin
  • /#/auth

Otherwise, point the requests to /viewer and preserve any provided parameters.

Example:

  • example.com/ should not be redirected.

  • example.com/#/admin/ should not be redirected.

  • example.com/#/Qsj7jw should be redirected to example.com/viewer/Qsj7jw.

MrWhite
  • 12,647
  • 4
  • 29
  • 41
jrance
  • 1
  • 2

1 Answers1

0

example.com/#/Qsj7jw should be redirected to example.com/viewer/Qsj7jw.

Basically, you can't do this type of redirection server-side in .htaccess.

The fragment identifier (ie. everything after the #) is not even sent to the server (the browser strips it from the request), so the server (ie. .htaccess) only ever sees example.com/ in the above request.

Fragment identifiers are used solely for client-side manipulation/navigation. eg. with JavaScript.

MrWhite
  • 12,647
  • 4
  • 29
  • 41