开发者

Store URL Keywords in database, or derrive

开发者 https://www.devze.com 2023-02-19 02:40 出处:网络
If I have a book named \"The Harold\'s Purple Crayon Collectors Set,\" I want the website URL to look like this:

If I have a book named "The Harold's Purple Crayon Collectors Set," I want the website URL to look like this:

www.site.com/book/harolds-purple-crayon/4324

I will need to write code to strip out things like noise words, special characters, words less than x chars long, limiting the final result to y words, etc, bu开发者_运维技巧t after that code is written, what do I do with it?

Do I run each title through the code every time the URL is needed on my site, or instead, use the code to loop through all my titles and dump the results into a database and pull them from there instead of dynamically building them each time?


The best practice in this case is to save the friendly-URLs to the database and have them retrieved together with other information about that book (in this case). Next, all you have to do is to re-create the URL, using the string you generated and the ID (as per your example).

0

精彩评论

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