Requirements:
1. Valid UBB.Threads 7.5.8 install and license.
2. The PATH_INFO environmental variable must be available for this feature to function properly.
About:
This mod converts UBBT's Spider-Friendly URL string to lower-case and strips it of HTML tags. It then uses php's regular expression "replace" to replace everything not a letter or a number with dashes (it also replaces spaces). Next, it replaces all double-dashes with a single dash (if the topic title string had "nom – nom nom" that previously would be four dashes – now it's just two) and then finally, it trims any extra dashes from the beginning and end of the string.
Example 1 -
BEFORE:
ubbthreads.php/topics/45/I_Like...._TURTLES!!!!.html
AFTER:
ubbthreads.php/topics/45/i-like-turtles.html
Example 2 -
BEFORE:
ubbthreads.php/topics/44/LoL,_?,_<,_>,_",_&,_,,_+,_|,_!,__,_#,_\,_^,_{,_},_=,_:,.html
AFTER:
ubbthreads.php/topics/44/lol.html
Warning:
If your forum's language uses any non UTF-8 characters, such as the Swedish å, ä and ö, they will be stripped. See Example 2 above.
Notes:
Using dashes/hyphens (-) rather than underscores (_) for spider-friendly URLs is the recommended format to follow and is this current standard rather than use the older style of underscores-for-spaces, which UBB.Threads uses. Some further reading on the use of hyphens (-) vs underscores (_):
http://www.ecreativeim.com/blog/2011/03/seo-basics-hyphen-or-underscore-for-seo-urls/The short answer is that you should use a hyphen for your SEO URLs. Google treats a hyphen as a word separator, but does not treat an underscore that way. Google treats and underscore as a word joiner — so red_sneakers is the same as redsneakers to Google. This has been confirmed directly by Google themselves, including the fact that using dashes over underscores will have a (minor) ranking benefit.
Again, SEO URLs should use hyphens to separate words. Do not use underscores, do not try to use spaces, and do not smash all the words together intoonebigword. As of 2012, dashes are still the best way to optimize your SEO URLs.
A video answering the hyphen vs underscore SEO URL question by
Matt Cutts.
Matthew "Matt" Cutts leads the Webspam team at Google, and works with the search quality team on search engine optimization issues
YouTube Video:
https://www.youtube.com/watch?v=AQcSFsQyct8How-To:
Confirm that Spider-friendly URLs are turned on:
Control Panel > Primary Settings > Advanced Options > Enable Spider-friendly URLs TICK-BOX
Optional: Tick also the "Enable HTML Extension" box.
FIND IN libs/ubbthreads.inc.php:
$title = ubbchars($title);
$title = str_replace(' ', '_', trim($title));
$title = str_replace( '%', '_', $title );
$title = substr($title, 0, 30);
REPLACE WITH:
//SEO-friendly URL String Converter
//ex) this is an example -> this-is-an-example
$title = str_replace(array("&"," "), " ", $title); //replace space and ampersand markup
$title = str_replace(array(""","'"), "", $title); //replace quote markup
$title = mb_convert_case($title, MB_CASE_LOWER, "UTF-8"); //convert to lowercase
$title = preg_replace("#[^A-Za-z0-9]+#", "-", $title); //replace everything non-alphameric with dashes
$title = preg_replace("#(-){2,}#", "$1", $title); //replace multiple dashes with one
$title = trim($title, "-"); //trim dashes from beginning and end of string if any
$title = substr($title, 0, 70);
done.
---
Further reading on why this simple modification is necessary in UBB.threads 7.5.8:
"Six show-stopping problems with UBBT 7.5.8's new Spider-Friendly SEO URLs"
http://www.ubbcentral.com/forums/ubbthreads.php/topics/255500