在Django中,配置 APPEND_SLASH
为true
后,会给所有的网址结尾都会给加上'/'
比如
http://example.com/post 自动转到 http://example.com/post/
这种方法挺好的,我用Flask做的应用
http://example.com/post # 正常访问 http://example.com/post/ # 访问这个就404了
不知道flask中有没有这种重定向的功能,我看flask官方网站会自动加上'/'
你定义的url规则尾巴上有“/”就行。