Pligg CMS Forums


Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials



SEO Mod for URL Method 2

Advanced Tutorials for Modifying your Pligg site


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-17-2007, 11:22 PM
New Pligger
 
Join Date: Dec 2006
Posts: 22
SEO Mod for URL Method 2

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 03:14 AM.
Reply With Quote
Sponsor
  #2 (permalink)  
Old 02-18-2007, 09:49 AM
Constant Pligger
Pligg Version: 9.8
Pligg Template: garx mod
 
Join Date: Oct 2006
Location: Poland
Posts: 135
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 09:55 AM.
Reply With Quote
  #3 (permalink)  
Old 02-20-2007, 02:34 PM
New Pligger
 
Join Date: Nov 2006
Posts: 25
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, 04:50 PM
New Pligger
 
Join Date: Dec 2006
Posts: 22
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, 08: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, 06:04 AM
Casual Pligger
 
Join Date: Mar 2007
Posts: 63
Dashes vs underscores

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, 10: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-10-2007, 11:49 PM
New Pligger
 
Join Date: Nov 2006
Posts: 25
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
Has anyone got Friendly Urls (Url Method 2) working? revolver General Help 11 05-08-2008 12:32 AM
Sort news options on Published/Upcoming tabs do not support Voting Method 2 aaronpais Modification Tutorials 2 05-19-2007 10:31 AM
url method 2 advancement davebowker General Help 10 02-11-2007 05:45 PM

Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Use the coupon code PLIGG at Dreamhost.com to receive a discount of up to $84.00 Make a donation to support Pligg CMS development