Making keyword rich, human readable URLs
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
I never have duplicates. I include the ID i've pulled from a database in the URL.
forums/view-topic/12345/some-topic-title.html
forums/view-topic/12345/some-topic-title.html
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Good call. I edited the original post to include another parameter that defaults to 'no-title'. Lots of paramter calls =/ But the function works!
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
What about just failing on a "null" input... if i enter !@#!@#*!&@#(*&!@# it's going to spit out '', but instead of blindly accepting it and turning it into something the user wont be expecting (and therefore probably just re-enter the same data), you just return to the form page with an error, "Only use a-z,0-9,etc in your title"
I probably will classalize it. Good call with the empty(), I would've never caught that myself.Ambush Commander wrote:At this point I would have turned into a class...
Note that using empty() will also cause pages called "0" to be switched to blank.
That would defeat the purpose of what this does. If they put in something like that, they likely don't care about the title anyways.nickvd wrote:What about just failing on a "null" input... if i enter !@#!@#*!&@#(*&!@# it's going to spit out '', but instead of blindly accepting it and turning it into something the user wont be expecting (and therefore probably just re-enter the same data), you just return to the form page with an error, "Only use a-z,0-9,etc in your title"
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Alright, I turned it into the shortest class ever. I added a default maxlength of 50. I probably won't do too much more to it. Hopefully someone else will find it useful. ;d Thanks for the tips everyone!
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- DaveTheAve
- Forum Contributor
- Posts: 385
- Joined: Tue Oct 03, 2006 2:25 pm
- Location: 127.0.0.1
- Contact:
*cough* Don't Look Here *cough*
I already suggested that... it's not what he's looking for... this is for something else.DaveTheAve wrote:*cough* Don't Look Here *cough*
A lot of you are missing the point 
The point is keyword rich - human readable, urls.
For example, I recently started using this on my forums.
The world news & current events forum
- Before - showforum.php?forumid=21
- After - forums/21/world-news-and-current-events/index.php
A topic in that forum.....
- Before - showthread.php?threadid=22107
- After - forums/view-topic/22107/yet-another-school-shooting.php
That would look terrible if it were yet%20another%20school%20shooting%2E.php
The point is keyword rich - human readable, urls.
For example, I recently started using this on my forums.
The world news & current events forum
- Before - showforum.php?forumid=21
- After - forums/21/world-news-and-current-events/index.php
A topic in that forum.....
- Before - showthread.php?threadid=22107
- After - forums/view-topic/22107/yet-another-school-shooting.php
That would look terrible if it were yet%20another%20school%20shooting%2E.php
I can't, it's a closed forum.Have you posted it in the code snippets?
Last edited by s.dot on Wed Oct 04, 2006 3:31 pm, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- DaveTheAve
- Forum Contributor
- Posts: 385
- Joined: Tue Oct 03, 2006 2:25 pm
- Location: 127.0.0.1
- Contact:
Well, that was done with .htaccess.... and you could implatment the dashes with this:scottayy wrote: - Before - showthread.php?threadid=22107
- After - forums/view-topic/22107/yet-another-school-shooting.php
That would look terrible if it were yet%20another%20school%20shooting%2E.php
Code: Select all
$url = urlencode($_GET['url']);
$url = str_replace("%20","-",$url);