如何从URL重写中删除#

问题描述

我们的网址中的程序中包含#,我们如何向用户隐藏它

example: www.example.com/#/privacypolicy

需要将其更改为www.example.com/privacypolicy

是使用webconfig实现此目标的任何方式

解决方法

URL在#之后不会发送任何内容到服务器,这意味着服务器不会获得隐私策略的一部分,因此使用url.encode是使完整的url发送到服务器的好方法。 URL中的哈希标签是为客户端浏览器而不是服务器提供特殊目的的,因此浏览器在'#'字符之后没有任何作用。

 <rule name="#" enabled="true" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_URI}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="http://www.example.com/{UrlEncode:{C:1}}" />

这将使enter image description here成为www.example.com/#/privacypolicy,以便服务器可以获得隐私策略。