I wanted underscores in my link titles instead of dashes, which is better seo for directories.
i.e.
yoursite.com/pligg-is-great/
is now
yoursite.com/pligg_is_great/
Is somehow more "readable" to the almighty's standards.
I'll post my libs/utils.php makeUrlFriendly function but don't expect it to work for you, it's kinda proof of concept, because my function is hacked up anyway
Code:
function makeUrlFriendly($input) {
// this function taken from http://us2.php.net/manual/en/function.preg-replace.php#54517
// then modified with the help of "j0zf" and "caomhin"
Global $db;
//steef: remove strange characters in friendly URLs (code by jalso)
//w3c: escape the url using urlencode() when it has to be displayed.
//$input = remove_error_creating_chars(utf8_substr($input, 0, 240));
$input = utf8_substr($input, 0, 240);
// I wanted to keep these in ??? $output = preg_replace("/\b(an?d?|f?o(r|f)|the)\b/i" , "" , $input);
// Replace spaces with underscores
$output = preg_replace("/\s/e" , "_" , $input); //here is the modified line
$output = trim($output);
// Remove non-word characters // this will break unicode chars
//$output = preg_replace("/\W/e" , "" , $output);
//$output = preg_replace( '/(_a_|_an_|_the_|_and_|_or_|_of_|_for_)/i', '_', $output );
$output = str_replace("-", "", $output);
$output = str_replace("--", "_", $output);
$output = str_replace("\"", "", $output);
$output = str_replace("'", "", $output);
$output = str_replace(",", "", $output);
$output = str_replace(".", "", $output);
$n = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_title_url like '$output%'");
if ($n > 0)
{return $output . "-$n";}
else
{return $output;}
}
ithis is an example...
Code:
RewriteRule ^story/title/([a-zA-Z0-9-_]+)/?$ story.php?title=$1 [L]







Linear Mode




