问题描述
是否有与Apache.mod_rewrite一样的Node.js等效模块?还是有一个提供等效功能的标准语言构造?
Is there an equivalent module for Node.js that does what Apache's mod_rewrite does? or is there a standard language construct that provides equivalent functionality?
我刚刚开始使用Node并希望将服务器转换为该平台.
I'm just getting started with Node and looking to convert my server to this platform.
推荐答案
如前面的答案所建议,您需要自己编写;前面的两个答案都更倾向于专门处理不同的路径.
As suggested by the previous answers you need to write it yourself; the two previous answers were both more orientated towards handling different paths specially.
您可能会发现我的节点反向代理很有帮助,因为它有很多帮助处理重写规则的代码集.这与以前的答案不同,因为它允许您匹配"/people/([[az] *)""规则,然后重定向到非常相似的"/cgi-bin/index.cgi?user=$1"进行mod_rewrite.
You might find my node reverse proxy helpful, as it has a lot of code for handling rewrite rules. This is different than the previous answers because it allows you to match on a rule such as "/people/([a-z]*)" and redirect to "/cgi-bin/index.cgi?user=$1" which is very similar to mod_rewrite.
这篇关于apache mod_rewrite是否等效于node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!