SEO Mod for URL Method 2

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-18-2007, 12:22 AM
New Pligger
 
Join Date: Dec 2006
Posts: 20
To satisfy the almighty google, I started fooling around with utils.php after a problem I had with the url input and creation.

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;}

}
You also have to change your .htaccess when it comes to a "story" rule. EVERY SINGLE OCCURANCE,

ithis is an example...

Code:
RewriteRule ^story/title/([a-zA-Z0-9-_]+)/?$ story.php?title=$1 [L]
notice the addidtion of the underscore, you could replace the trailing dash after the 9 but I still have stories with dashes, and I probably won't go back and change them.

Last edited by riggd; 02-18-2007 at 04:14 AM.
Reply With Quote
  #2 (permalink)  
Old 02-18-2007, 10:49 AM
Constant Pligger
Pligg Version: 9.8
Pligg Template: garx mod
 
Join Date: Oct 2006
Location: Poland
Posts: 124
renaming - to _ working ok, but modrewrite not

all [a-zA-Z0-9] in .htaccess i must rename to [a-zA-Z0-9-_] ?

Last edited by daone; 02-18-2007 at 10:55 AM.
Reply With Quote
  #3 (permalink)  
Old 02-20-2007, 03:34 PM
New Pligger
 
Join Date: Nov 2006
Posts: 20
where do you get the idea that underscores are better for seo?

Everything I've read/seen makes it clear that dashes are much preferred.

http://www.mattcutts.com/blog/dashes-vs-underscores/
Reply With Quote
  #4 (permalink)  
Old 02-20-2007, 05:50 PM
New Pligger
 
Join Date: Dec 2006
Posts: 20
Well, that article was written in 2005, and about his personal experiences.

All I have read says the opposite, but I don't have any links to reference, just many forums and blogs I visit.

I can only give you 2 hard examples...

1.Digg

2.If you run adsense, you will get EXTREMELY relevant directed results for underscores in directories. If you have a spare domain, try it out for yourself.

If I remember correctly they treat underscores as spaces and drop dashes, lumping the string together. I will hunt for some documentation if you like.

I would like to hear what others have read and understand on the issue if anyone else has any information.
Reply With Quote
  #5 (permalink)  
Old 02-21-2007, 09:09 AM
New Pligger
 
Join Date: Feb 2007
Posts: 13
Quote:
Originally Posted by riggd View Post
I will hunt for some documentation if you like.
please do that
Reply With Quote
  #6 (permalink)  
Old 03-16-2007, 07:04 AM
Casual Pligger
 
Join Date: Mar 2007
Posts: 57
Matt Cutts is the Google spam head; and he is considered the authority in such questions. Most top end SEOs use dashes now.

Relevant ads depend on too many other factors.

Quote:
Originally Posted by pligiro View Post
please do that
Reply With Quote
  #7 (permalink)  
Old 03-20-2007, 11:07 AM
New Pligger
 
Join Date: Mar 2007
Posts: 7
Having spent the last 3 years as an SEO I would have to place my vote with the dashes over the underscore. We saw such a dramatic improvement when I switched to dashes instead of underscores (which was the company standard at the time) that we ended up going over all our work and changing underscores to dashes.
Of course SEO like anything else you can always find someone who has a different view point.
Reply With Quote
  #8 (permalink)  
Old 07-11-2007, 12:49 AM
New Pligger
 
Join Date: Nov 2006
Posts: 20
Why was the default changed back to underscores?

Anyone point me to where I would change this to get back to dashes in the url?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
url method 2 advancement davebowker Questions and Comments 15 Today 07:15 AM
FIX for gzip compression troubles, no .htaccess gzip compression method required Daniel Questions and Comments 9 06-07-2010 09:06 AM
Using Search Method 4 - Tags will not work hotsitez Questions and Comments 11 11-29-2008 08:54 PM
Has anyone got Friendly Urls (Url Method 2) working? revolver Questions and Comments 11 05-08-2008 01:32 AM
Search Method 3 and 4 in Pligg version 9.8.2 broke Iceburg Questions and Comments 3 11-03-2007 08:03 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development