physaux Posted November 9, 2009 Share Posted November 9, 2009 Hey guys, I want to create new pages on my site. However, I want the pages to be like so: www.mysite.com/.../989said9asdua9s-the-title-of-my-page.html So I am trying to create a url with the title words in it. But I want to take precautions incase I end up making 2 pages with the same name. So i want the random number part (989said9asdua9s) to be unique for every title string. Would this work: check if the title is unique, if it is then the url is just: md4/5(title).urlencode(title).".html"; If the title is not unique, I add some random string/numbers to the title inside of the md4/5, and the url is: md4/5(title.randomString()).urlencode(title).".html"; //I would make randomstring as a function. So I would loop this until the url is unique. Does that sound like a good plan? or could something go horribly wrong that I do not see. I don't want the random string to be too long, and so is md4 or md5 right for this? or does anyone have any other suggestions? thanks!! EDIT: incase of appending random strings, I could just append something unique to the page, such as it's ID or whatever... So the question becomes, is md5/4 good for this? Is this a good idea? Is there a better way? Link to comment https://forums.phpfreaks.com/topic/180873-solved-using-md5or-md4-to-create-a-unique-hash-help-please/ Share on other sites More sharing options...
JonnoTheDev Posted November 9, 2009 Share Posted November 9, 2009 Why are you creating static pages? Is the content not stored in a database? If so you only require 1 file. A mod-rewrite, can include the page name in the url. Use the primary key as the page identifier i.e /page-title/23.html /another-page-title/24.html Both pages are index.php?id= Link to comment https://forums.phpfreaks.com/topic/180873-solved-using-md5or-md4-to-create-a-unique-hash-help-please/#findComment-954183 Share on other sites More sharing options...
physaux Posted November 9, 2009 Author Share Posted November 9, 2009 Can you explain what you mean exactly when you say I only need one file? Say each of my files can be generated from a "pageid" from a database, I thought I had to create many different pages like this: <?php $pageid = 8; include("genericpage"); ?> How do I do it like you are saying? Link to comment https://forums.phpfreaks.com/topic/180873-solved-using-md5or-md4-to-create-a-unique-hash-help-please/#findComment-954189 Share on other sites More sharing options...
physaux Posted November 9, 2009 Author Share Posted November 9, 2009 Nevermind, google got my back on this 1 thanks for telling me about mod-rewrite! Link to comment https://forums.phpfreaks.com/topic/180873-solved-using-md5or-md4-to-create-a-unique-hash-help-please/#findComment-954201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.