What is the best practice for URL rewriting a Blog Article Address?

What is the best practice for URL rewriting a Blog Article Address?

浮生未歇 发布于 2021-11-27 字数 545 浏览 738 回复 1 原文

I see many sites that have address like this:

http://www.myblog/2008/10/10/articl-title.aspx

Question 1

If I am using linq2sql to pull the article it is obvious that i must search for article in db using Startwith() function, but is this really smart and precise over searching using the ID ?

Question 2
What is the best way to make the URL look neat like this and add the ID and make search engine friendly at the same time?

thanks in advance.

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

扫码加入群聊

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面犯桃花 2022-06-07 1 楼

Well, a very simple alternative is the trick that SO uses; include both the internal identifier and the search-friendly portion - i.e.

http://stackoverflow.com/questions/793908/what-is-the-best-practice-for-urlrewriting-a-blog-article-adress

just only look at the identifier. With ASP.NET MVC routes this is trivial.

If you go the other route (no db identifier in the route); simply store the mangled name/path in the db - then your query is an equality one = very efficient.