Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jul 2001
Posts: 1,157
Likes: 82
coffee and code
coffee and code
Joined: Jul 2001
Posts: 1,157
Likes: 82
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/

Quote
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=AQcSFsQyct8


How-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:
Code

$title = ubbchars($title);
$title = str_replace(' ', '_', trim($title));
$title = str_replace( '%', '_', $title );
$title = substr($title, 0, 30);

REPLACE WITH:
Code

//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

Last edited by id242; 07/27/2014 5:04 PM.

Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com
Sponsored Links
Entire Thread
Subject Posted By Posted
[7.5.8] Better URL Sanitization for SEO isaac 03/18/2014 9:20 AM
Re: [7.5.8] Better URL Sanitization for SEO Gizmo 03/18/2014 10:30 AM
Re: [7.5.8] Better URL Sanitization for SEO isaac 07/27/2014 10:22 PM
Re: [7.5.8] Better URL Sanitization for SEO Gizmo 07/27/2014 11:29 PM
Re: [7.5.8] Better URL Sanitization for SEO isaac 07/28/2014 12:23 AM
Re: [7.5.8] Better URL Sanitization for SEO Mark_S 09/05/2015 4:25 AM
Re: [7.5.8] Better URL Sanitization for SEO Gizmo 09/05/2015 1:33 PM
Re: [7.5.8] Better URL Sanitization for SEO Mark_S 09/06/2015 4:56 PM
Re: [7.5.8] Better URL Sanitization for SEO Gizmo 09/06/2015 10:26 PM
Re: [7.5.8] Better URL Sanitization for SEO Mark_S 09/07/2015 12:32 AM
Url fails Mark_S 09/27/2015 2:50 PM
Re: Url fails Gizmo 09/27/2015 10:04 PM
Re: Url fails isaac 09/27/2015 10:16 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)