Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,如果用户键入http://myurl.com/arti
它将重定向到 404 页面,我在其中显示 url
/article(类似的链接)
您可以使用一个包罗万象的 URL,例如url(r"^(.*)$"作为您的最后一个条目urls.py,然后使用一些字符串相似性度量来查找可能的 URL。有关示例,请参见此问题。或者这个更多的。
url(r"^(.*)$"
urls.py
或者也许只是对已知网址的简单startswith()循环就可以了?
startswith()
如果只有一个匹配项,您的视图可能应该返回一个带有重定向(结果代码302或303)的响应 - 如果没有(或多个)一个404包含可能匹配项列表的页面是要走的路。
302
303
404