任何人都可以帮助我,我想重写http://www.example.in/search?city=' xyz' 至 http://www.example.in/city/xyz 在sails.js
答案 0 :(得分:0)
查看文档的url slug部分。
你可以像这样创建一条路线:
// config/routes.js
module.exports.routes = {
// The simple route you use to access to the search controller for now
'get /search': 'SearchController.index'
// The "rewritten" route that calls the same controller
// processing ":city" as if it was part of the query string
'get /city/:city': 'SearchController.index'
}
然后,http://www.example.in/search?city=xyz
和http://www.example.in/city/xyz
将具有相同的结果,就像您使用网址重写Nginx或Apache一样。