Updated November 02, 2017
You may want to use a # (Anchor tag or hash) within the destination URL you are rewriting or redirecting to and find that the resulting URL contains %23tag instead of #tag. Lets take a look at an example:
[sourcecode]
RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,L]
[/sourcecode]
The resulting URL in the browser will be :
https://example.com/sample/%23tag
You can simply use the NE flag (noescape). Using this flag will prevent the special characters from being converted to their hexcode equivalent.
[sourcecode]
RewriteCond %{REQUEST_URI} /sample\.php$
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule .* https://example.com/sample/#tag [R=301,NE,L]
[/sourcecode]
The resulting URL will be:
https://example.com/sample/#tag
That’s it, you can now use # in the destination URL
This was a life saver. Seems like order is important, so make sure NE is at the front of the list of flags
THANK YOU you saved me