问题描述
我需要把
/module/index.html#/
转成
/index#/
不要前面的module
/module/merchant.html#/
转成
/merchant#/
我写的
rewrite ^/module/index.html(.*)$ /index#/$1;
直接404b
问题解答
回答1:#后面的数据是HTML页面处理的,而不是路由处理的,所以你的重写规则应该是:
rewrite ^/module/(.+).html$ /$1
就可以了。
你需要做的只是把.html和/module/去掉而已。
另外,我不知道你是想地址写/module/index.html,来访问/index,还是地址写/index来访问/module/index.html,如果是后者的话,就不是上面那个了,应该是:
rewrite ^/(.+)$ /module/$1.html回答2:
不好意思,服务端拿不到 URL 的 # 后面的数据, 这部分就只能在前端处理。