我使用MongoDB / mongoose存储具有以下架构的博客帖子:
PostSchema = mongoose.Schema({
title: {type: String},
body: {type: String}
});
现在我的帖子网址如下所示:http://www.example.local/posts/571f78d077b4454bafcfcced
我希望我的帖子包含如下的slug:
http://www.example.local/posts/571f78d077b4454bafcfcced/how-to-make-and-store-slug-for-title
所以我的问题是:
http://www.example.local/posts/571f78d077b4454bafcfcced
重定向到http://www.example.local/posts/571f78d077b4454bafcfcced/how-to-make-and-store-slug-for-title
(nodejs,nginx,客户端)。谢谢!
EIDT:我还发现在StackOverflow Database viwer中,对于id为503429的qoestion,SO存储非slugged标题。那么这是否意味着每当问题被要求时,SO会计算出slu?吗?