nginx rewrite 写来不生效
本文介绍了nginx rewrite 写来不生效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
我需要把
/module/index.html#/
转成
/index#/
不要前面的module
/module/merchant.html#/
转成
/merchant#/
我写的
rewrite ^/module/index.html(.*)$ /index#/$1;
直接404b
解决方案
#
后面的数据是HTML页面处理的,而不是路由处理的,所以你的重写规则应该是:
rewrite ^/module/(.+)\.html$ /$1
就可以了。
你需要做的只是把.html
和/module/
去掉而已。
另外,我不知道你是想地址写/module/index.html
,来访问/index
,还是地址写/index
来访问/module/index.html
,如果是后者的话,就不是上面那个了,应该是:
rewrite ^/(.+)$ /module/$1.html
这篇关于nginx rewrite 写来不生效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文