我如何重定向页/页#锚
到 http://www.example.com/page/page
。
我尝试以下code,但它不工作
I tried the following code, but it's not working
RewriteRule ^page/page#anchor http://www.example.com/page/page [NE,L]
你能帮帮我吗?
Could you please help me?
彼得·
这不能以来URI组件服务器端后#
做的是通过客户端只处理
That can't be done on server side since URI component after #
is handled by client side only.
您也可以使用这个JavaScript code做相同的:
You can alternatively use this Javascript code to do the same:
<script>
if (location.href.indexOf("#") > -1) {
location.assign(location.href.replace(/(page/page)#anchor/i, "$1"));
}
</script>