Go Back   Pligg Forum > Pligg Development > Pligg Mods
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-17-2007, 10:22 PM
riggd riggd is offline
New Pligger
 
Join Date: Dec 2006
Posts: 22
Downloads: 5
Uploads: 0
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 02:14 AM.
Reply With Quote
Sponsored Links
Check out the New Templates at the Pligg Pro Shop.
  #2 (permalink)  
Old 02-18-2007, 08:49 AM
daone daone is offline
Constant Pligger
Pligg Version: 9.8
Pligg Template: garx mod
 
Join Date: Oct 2006
Location: Poland
Posts: 135
Downloads: 5
Uploads: 0
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 08:55 AM.
Reply With Quote
  #3 (permalink)  
Old 02-20-2007, 01:34 PM
mBeat mBeat is offline
New Pligger
 
Join Date: Nov 2006
Posts: 25
Downloads: 1
Uploads: 0
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, 03:50 PM
riggd riggd is offline
New Pligger
 
Join Date: Dec 2006
Posts: 22
Downloads: 5
Uploads: 0
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, 07:09 AM
pligiro pligiro is offline
New Pligger
 
Join Date: Feb 2007
Posts: 13
Downloads: 7
Uploads: 0
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, 05:04 AM
wanderingmind wanderingmind is offline
Casual Pligger
 
Join Date: Mar 2007
Posts: 64
Downloads: 5
Uploads: 0
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, 09:07 AM
rlongfield rlongfield is offline
New Pligger
 
Join Date: Mar 2007
Posts: 7
Downloads: 3
Uploads: 0
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, 10:49 PM
mBeat mBeat is offline
New Pligger
 
Join Date: Nov 2006
Posts: 25
Downloads: 1
Uploads: 0
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

vB 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
Has anyone got Friendly Urls (Url Method 2) working? revolver General Help 11 05-07-2008 11:32 PM
FIX for gzip compression troubles, no .htaccess gzip compression method required Daniel Core Development 8 02-16-2007 02:16 PM
url method 2 advancement davebowker General Help 10 02-11-2007 04:45 PM
Url Method page added to Pligg wiki revolver Suggestions 1 11-04-2006 06:06 PM
URL Method nish Bug Report 4 09-16-2006 03:01 PM


LinkBacks Enabled by vBSEO 3.0.0