Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-17-2007, 11:22 PM
New Pligger
 
Join Date: Dec 2006
Posts: 22
Thanks: 0
Thanked 7 Times in 3 Posts
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.
__________________
Nick

http://riggd.com

Last edited by riggd; 02-18-2007 at 03:14 AM..
Reply With Quote
  #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: 134
Thanks: 11
Thanked 6 Times in 5 Posts
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
Thanks: 12
Thanked 1 Time in 1 Post
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/
__________________
http://www.mobilitybeat.com
Reply With Quote
  #4 (permalink)  
Old 02-20-2007, 04:50 PM
New Pligger
 
Join Date: Dec 2006
Posts: 22
Thanks: 0
Thanked 7 Times in 3 Posts
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.
__________________
Nick

http://riggd.com
Reply With Quote
  #5 (permalink)  
Old 02-21-2007, 08:09 AM
New Pligger
 
Join Date: Feb 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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
Thanks: 9
Thanked 4 Times in 4 Posts
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
Thanks: 2
Thanked 1 Time in 1 Post
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
The Following User Says Thank You to rlongfield For This Useful Post:
  #8 (permalink)  
Old 07-10-2007, 11:49 PM
New Pligger
 
Join Date: Nov 2006
Posts: 25
Thanks: 12
Thanked 1 Time in 1 Post
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?
__________________
http://www.mobilitybeat.com
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect Links with Admin User Management Page Numbers with URL Method 2 NewsHeatDotCom Bug Report 0 06-17-2008 02:41 PM
Has anyone got Friendly Urls (Url Method 2) working? revolver General Help 11 05-08-2008 12:32 AM
Search Method 3 and 4 in Pligg version 9.8.2 broke Iceburg Bug Report 3 11-03-2007 07:03 PM
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


Search Engine Friendly URLs by vBSEO 3.2.0