View Full Version : google: hypen and underscores
Hi!
Referring to http://www.prweaver.com/blog/2004/08/26/2-hyphen-and-underscore
I would like to change all "_" in the directories table to "-".
Please let me know the SQL command for that.
Thanks,
gb
figured it out already. you would need to use:
UPDATE dir_categories
SET path=(
REPLACE (`path`,
'_',
'-'));
Vincent Wright
09-13-2006, 07:35 PM
Thanks Gerwin -- nice trick.
Be VERY careful about doing this as while one or two hyphens are acceptable, if you have upwards of that it can be seen as spamming the search engines, and Google will take action.
While directory.com/cheap-cars/cars.php is acceptable
directory.com/cheap-cars/cars-for-sale/cheap-honda-cars/cars.php will get you into trouble, if not now then sometime soon. This is not my opinion it is the result of a statement from Matt Cutts a senior Google engineer.
Vincent Wright
09-14-2006, 03:34 AM
Probably the optimal soltion would be to have one-level cat paths:
e.g. dir/sub-sub-cat/
instead of
dir/cat/sub-cat/../sub-sub-cat/
In this case you have hyphens but their number is small enough.
hmm... the article i was referring to was a bit old (2004)
Seems that google wasn't sleeping that time...
i will think about it.
:fool:
Vincent Wright
09-14-2006, 08:34 AM
Two years are pretty much in IT industry...
safatweb
09-14-2006, 03:34 PM
I saw DMOZ itself using "_"
check http://www.dmoz.com/Regional/Asia/Philippines/Provinces/Southern_Leyte/
thanks
subseo
09-14-2006, 06:03 PM
hmm... the article i was referring to was a bit old (2004)
Seems that google wasn't sleeping that time...
I believe it is not whether - sign is good or bad. It is still good. If I remember correctly, it was semi-officially recommended by Google.
The reasoning why _ is slighly worse, had to do something with it's usage in programming languages and IT.
If you got 10 of them in a URL, it's a different thing. But alone, it would mean nothing. It would have to be combined with other factors for Google algorithm to decide that it is junk website. Google probably has way over 100 different factors it uses for ranking. I have seen some high quality blogs to have number of - in url, and no problem with ranking of course.
If anything, it would be just a secondary factor, or one of the factors.
OK gents,
Please understand that I ONLY post things as fact if I am CERTAIN of it as such.
here is the information you need and it is taken from Matt Cutts' Blog. Matt is a SENIOR google engineer and is also the official spokesman for google at SES and other webmaster conferences.
Quote-
To answer a common question, Google doesn’t algorithmically penalize for dashes in the url. Of course I can only speak for Google, not other search engines. And bear in mind that if your domain looks like www.buy-cheap-viagra-online-while-consolidating-your-debt-so-you-can-play-texas-holdem-while-watching-porn.com, that may still attract attention for other reasons.
quote!
Now Matt has also stated that too many hyphens while not getting you penalised, will possibly get you noticed. In this case he is referring to the actual words being used as drawing attention.
The delimiter effect is discussed here
http://www.mattcutts.com/blog/guest-post-vanessa-fox-on-organic-site-review-session/
Vincent Wright
09-17-2006, 01:57 PM
I have also noticed that many blogs use hyphens in page names and they often show up in search results (we all know search engines like blogs). It seems to me that search engines do not penalize for using many hyphens in urls.
i will stick with hyphens now.
only one problem with that now:
i have updated my google sitemaps. fine.
but still the pages in google appear with underscores (probably not reindexed). Anyway those users are forwarded to the startpage than.
How will I SEO correctly tell google that this page has moved from ___ to --- ? In htaccess with 301 forwards? But how?
You need to use mod rewrite redirect match. It is not a simple fix though, it is a bit technical.
i did so. in case it is usefull for anybody, i post the htaccess part here:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^_]*)_(.*) /$1-$2 [L,R=301]
it changes underscores to hyphens if the old url from google index is called.
well done, and nice of you to post the code as well :) In case some of you want to try this, make sure you follow normal HTaccess procedure, as in download your existing, open it up in a text file, and add this code there.
i did so. in case it is usefull for anybody, i post the htaccess part here:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^_]*)_(.*) /$1-$2 [L,R=301]
it changes underscores to hyphens if the old url from google index is called.
Hmmm...this doesn't seem to be working for me. I am actually in the middle of switching to eSyndicat from another link directory program which used underscores. When I plugged the above into my .htaccess it tells me that the URL that is being redirected to doesn't exist, when clearly it does. However, sometimes it just redirects to the main index.
Just to make sure I'm understanding what this does - if the visitor tries to go to www.url.com/category/sub_category it redirects to www.url.com/category/sub-category, correct?
Edited to add: I just realized that if I do not include the trailing slash at the end of the URL it gives me a 404 whether I'm accessing the real URL or the redirect - I think I know how to fix that, but if I do include the trailing slash it's still not right; the URL in the browser location bar changes like it is being redirected, but the page that comes up is just the main index.
Hi Erik!
The htaccess lines above is not the full MOD. You will also need to tell esyndicat to use - instead of _
You will only need to use this if your directory is running for a while already with underscores and has many pages index by google. With the 301 you tell also google that the underscore pages have moved to the hyphen ones.
The traling slash is another problem, that can be also fixed with an htaccess line. I will post a MOD later for both.
i have seen that the 1.2 Pro Version has already hyphens as standard, so it is obsolete to post a own mod for that.
If you have an older directory, and you want to change from underscores to hyphens you need to do the following things:
ALWAYS MAKE BACKUPS BEFORE!
a.) update your database:
in phpmyadmin go to SQL interface and enter the following
UPDATE dir_categories
SET path=(
REPLACE (`path`,
'_',
'-'));
this will replace the underscores to hyphens.
b.) in util.php check that the function covert_str looks like this:
function convert_str($aParams)
{
$aParams['string'] = strtolower($aParams['string']);
$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
$aParams['string'] = trim($aParams['string'], '-');
return $aParams['string'];
}
c.) in .htaccess add this three lines:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^_]*)_(.*) /$1-$2 [L,R=301]
note the two conditions, they say that it wont effect on files and directories that really exist (like images that have underscores inside).
Second thing, if you want that your categories show with or without / at the end to avoide those nasty 404 errors, add the following to your htaccess file:
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{HTTP_HOST} ^www.domain\.com$
RewriteRule (.*) http://www.domain.com/$1/ [R=301,L]
changing domain.com to your own... %)
vBulletin® v3.7.0, Copyright ©2000-2013, Jelsoft Enterprises Ltd.