Rewrite module replace char # to URL equivalent %23

70 Views Asked by At

How to replace in URL char # to its URL equivalent %23? Example:

https://example.com/common/rest/sitck?Param1=46694#2205923&Code=123

to

https://example.com/common/rest/sitck?Param1=46694%232205923&Code=123

1

There are 1 best solutions below

0
Stephen Ostermiller On

It is not possible to replace a # in a URL using a rewrite rule. The hash and everything that comes after it is called the "fragment identifier." That part of the URL is never sent to the server. It is client side only. Therefore it is not possible to manipulate it in a rewrite rule on the server.

The best you can do is examine the URL with client-side JavaScript. You can get and set the URL using the location.href variable in your web page.