The usual trick is to generate URLs like https://domain.com/blog/145/this-is-an-article <http://domain.com/blog/this-is-an-article>
where 145 is the id. The slug is just for show. On Monday, 18 May 2015 12:10:37 UTC-5, Jean-François Milants wrote: > > I found out that what I'm trying to do is a 'slug', a unique name for all > of my posts. > However, I'm worried about the performances of the search of the post in > DB. > > For example, when the user will enter this URL : > https://domain.com/blog/this-is-an-article > > A request will be made in DB to search for the string 'this-is-an-article > <http://domain.com/blog/this-is-an-article>'. This should'nt be an issue > for a small DB, but this could become a bottleneck when the DB will grow. > > How do you guys implement such a thing? > > > > Le samedi 16 mai 2015 16:41:36 UTC+2, Jean-François Milants a écrit : >> >> Hi, >> >> I'm writing a blog application, which allows me to create new blog post >> and have them listed on a page. >> >> In database, I have a table called "articles" which contains some field >> (id, title, content_text,...). >> >> For now, the URL to access to a specific blog post has the following >> structure : >> >> https://domain.com/blog/readArticle?articleId=23. >> >> Where : >> >> - Blog is the controller >> - readArticle() is the function that retrieves the blog article data >> - 23 is the ID of the article in the DB >> >> >> This is easy to implement, but no user/SEO friendly. >> >> I would like to improve the URL structure to something like: >> https://domain.com/blog/readArticle?article=this-is-an-article >> >> or >> https://domain.com/blog/this-is-an-article >> >> ... and I'm looking for the best way to do this. >> >> Should I modify my backend so that it will search the article based on >> its title (or 'slug'). >> Or should I use the 'router' in some advanced ways? >> >> I'm sure a lot of people has already done that. Any ideas or suggestions? >> >> Thanks! >> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

