开发者

Creating dynamic text URL rewrites to IDs - best practice?

I'm developing a site where there are a number of articles stored in a database with their re开发者_JS百科spective IDs. Each of these articles will have a SEO friendly text URL, which is then processed by PHP/.htaccess to fetch the matching article by its ID. What would be the best practice for accomplishing this?

For example, let's say I have this URL: www.mysite.com/articles/hello-world/. And it should take me to an article that has an ID of 4.

My best guess is I should add a column in the DB table that has that text string (added upon publishing the article).


Yes it is the best practice. I can't imagine any others


I am currently reading about Symfony and they have solved this "problem" adding a new column named 'slug' to the database, but anyway they show the ID in the url.

In this link they explain this, and show practices examples.

PS: Sorry my bad english.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜