• Home
  • Community
  • Submitted News
FAQ • Search • Login
Forum Home • Register

View unanswered posts | View active topics


Board index » Pligg » Pligg Marketing and SEO » SEO Hacks

All times are UTC


Pligg Google SEO Friendly URL Rewrite Hack



Post new topic Reply to topic  Page 1 of 2
 [ 17 posts ]  Go to page 1, 2  Next
Print view Previous topic | Next topic 
 Pligg Google SEO Friendly URL Rewrite Hack 
Author Message
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 263
Post Pligg Google SEO Friendly URL Rewrite Hack
A default Pligg story URL once rewritten looks like the example below.

Code:
http://www.designfloat.com/General/Joshua_Glenn_Taking_Things_Seriously/


What stands out is the use of _ Underscores within the URL, Google prefers the use of a hyphen/dash - as a separator and for more information on this read the Blog post by Matt Cutt’s who works for Google. This excerpt below taken from Matt’s blog post should indicate exactly why a hyphen/dash is a better separator. Visit Matt's Blog

Matt Cutts wrote:
With underscores, Google’s programmer roots are showing. Lots of computer programming languages have stuff like _MAXINT, which may be different than MAXINT. So if you have a url like word1_word2, Google will only return that page if the user searches for word1_word2 (which almost never happens). If you have a url like word1-word2, that page can be returned for the searches word1, word2, and even “word1 word2″.

So how do we fix this? luckily Adam over at Pligg Template has provided some code to clean up the Pligg URL system to be more Search Engine Friendly. We will use some of that code to achieve a nice clean URL system like below.


Code:
http://www.designfloat.com/general/joshua-glenn-taking-things-seriously/


Open libs/utils.php and FIND
Code:
$output = utf8_substr($input, 0, 240);


REPLACE WITH
Code:
$output = utf8_strtolower($input, 0, 240);


libs/utils.php and FIND
Code:
$output = str_replace("\"", "", $output);


REPLACE WITH
Code:
$output = str_replace(" - ", "-", $output);
$output = str_replace("_", "-", $output);
$output = str_replace("---", "-", $output);
$output = str_replace("\"", "", $output);
$output = str_replace("--", "-", $output);


Now you have lovely clean and Google friendly URL’s note for categories you must manually create categories in lowercase from the Admin section of pligg or your htaccess won’t work. Also this change should not be applied to an existing site unless you know how to 310 redirect content that is currently indexed under the old url system or you have a very small site with very little indexed story content.

To use a hypen for category seperator use the code below. At the moment pligg squashes category names together for example if your category is titled "Science & Technology" the URL of that category will look like this "sciencetechnology" this is bad for google. The code below will produce the URL to look like this "science-technology" which is much better.

OPEN /libs/utils.php

FIND
Code:
function makeCategoryFriendly($input) {

        $input = utf8_substr($input, 0, 240);

        $output = trim($input);

        $output = preg_replace("/\s/e", "", $output);         // remove spaces
        $output = str_replace("_", "", $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);
        $output = str_replace('?', '', $output);
        $output = str_replace('$', '', $output);

        if(function_exists('utils_makeUrlFriendly')) {
                $output = utils_makeUrlFriendly($output);
        }

        return urlencode($output);
}


REPLACE WITH

Code:
function makeCategoryFriendly($input) {

        $input = utf8_substr($input, 0, 240);

        $output = trim($input);
        $output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));

        $output = preg_replace("/\s/e", "_", $output);         // remove spaces
        $output = str_replace("_", "-", $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);
        $output = str_replace('!', '', $output);
        $output = str_replace('?', '', $output);
        $output = str_replace('$', '', $output);
        $output = str_replace("---", "-", $output);
        $output = str_replace("--", "-", $output);

        if(function_exists('utils_makeUrlFriendly')) {
                $output = utils_makeUrlFriendly($output);
        }

        return urlencode($output);
}


Tue Dec 25, 2007 1:36 am
Profile
juanmartinbravo

Joined: Tue Dec 25, 2007 10:47 pm
Posts: 6
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Hello,

I have some questions :roll:

Can it work on a subdomain like http://estosesale.com/news ? I tried to did it but it failed.
Could it be because it wasn't a "clean" pligg? I mean the site is already runining and I made beofre changes as creation of news, categories, friendly urls, urlmethod2.....
Should I activate the urlmethod2, friendly urls and modify the .htacces before doing that?

I aprecciate yor effort but as u can see my english is regular and moreover I am a pligg newbie so I wanna have everything clear ;)

Thanks


Tue Dec 25, 2007 11:49 pm
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 263
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Hi juanmartinbravo,

This hack will works on a subdomain like news. ;)

Create your categories first then modify your .htaccess file, remeber to check that your RewriteBase rule in your .htaccess says RewriteBase /news/ if you have pligg in a subdirectory. Also remeber an copy the categories htacces rules from you admisnistration section and paste them into th htaccess or url method 2 wont work for categories.

Applying this code will only work with URL method 2, the code changes do not efferct URL method 1 in any way.

Hope that helps :)


Tue Dec 25, 2007 11:56 pm
Profile
juanmartinbravo

Joined: Tue Dec 25, 2007 10:47 pm
Posts: 6
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Thank yuo very much for our prompt reply LincolnHawks :)

I did it, but it doesn't works it continues using the urls with _ instead of - :( For example:
http://estosesale.com/news/Reproductore ... _o_Itouch/

1-That's my .htaccess file:
Code:
##### Gzip Begin #####
## To enable Gzip and decrease the load times of your Pligg site
## change /home/path/to to your absolute server path and remove the two # from both lines
## php_value auto_prepend_file /home/path/to/begin_gzip.php
## php_value auto_append_file /home/path/to/end_gzip.php

AddType "text/javascript" .gz
AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{THE_REQUEST} ^(.*).js
RewriteCond %{SCRIPT_FILENAME}.gz -f
RewriteRule ^(.*)\.js $1.js.gz [L]
##### Gzip End #####

##### 404 Error Begin #####
## If Pligg is installed in a subfolder, change the below line to ErrorDocument 404 /name-of-subfolder/404error.php
ErrorDocument 404 /news/404error.php
##### 404 Error End #####

##### Re-directing Begin #####
Options +Indexes +FollowSymlinks
RewriteEngine on
## If Pligg is installed in a subfolder, change the below line to RewriteBase /name-of-subfolder
RewriteBase /news
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/

## Remove these two lines if you have a sub-domain like  http://ashdigg.pligg.com  or http://localhost
## Keep if your site it like   http://www.pligg.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##### Re-directing End #####

## Remove www., always.
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]

## Rewrites the index.php page to point to the domain default folder
RewriteCond %{THE_REQUEST} (index\.php) [NC]
RewriteRule ^(.*)index\.php$ http://yoursite.com/$1 [L,R=301]

##### You can find the below lines pre-made for you in the category management section of the admin panel ######
RewriteRule ^(all|Audio|Musica|Reproductoresmp3|Video|Moviles|Internet|Ordenadores|Software|Otrosgadgets)/([^/]+)/?$ story.php?title=$2 [L]
RewriteRule ^(all|Audio|Musica|Reproductoresmp3|Video|Moviles|Internet|Ordenadores|Software|Otrosgadgets)/?$ ?category=$1 [L]
#####

##### URL Method 2 ("Clean" URLs) Begin #####
RewriteRule ^story/([0-9]+)/?$ story.php?id=$1 [L]
RewriteRule ^story/title/([^/]+)/?$ story.php?title=$1 [L]
RewriteRule ^story/([0-9]+)/editcomment/([0-9]+)/?$ edit.php?id=$1&commentid=$2
RewriteRule ^story/([0-9]+)/edit/?$ editlink.php?id=$1
RewriteRule ^story/([0-9]+)/modify/([a-z]+)/?$ linkadmin.php?id=$1&action=$2
RewriteRule ^recommend/([a-zA-Z0-9-]+)/?$ recommend.php?id=$1 [L]
RewriteRule ^category/([^/]+)/?$ index.php?category=$1 [L]
RewriteRule ^upcoming/category/([^/]+)/?$ upcoming.php?category=$1 [L]
RewriteRule ^upcoming/([a-zA-Z0-9]+)/?$ upcoming.php?part=upcoming&order=$1
RewriteRule ^inbox/?$ user.php?view=inbox
RewriteRule ^user/?$ user.php
RewriteRule ^user/view/([a-zA-Z0-9-]+)/?$ user.php?view=$1
RewriteRule ^user/view/([a-zA-Z0-9+]+)/([a-zA-Z0-9+]+)/?$ user.php?view=$1&login=$2
RewriteRule ^user/view/([a-zA-Z0-9+]+)/login/([a-zA-Z0-9+]+)/?$ user.php?view=$1&login=$2
RewriteRule ^user/([a-zA-Z-]+)/link/([0-9+]+)/?$ user_add_remove_links.php?action=$1&link=$2
RewriteRule ^published/?$ index.php
RewriteRule ^published/([a-zA-Z0-9-]+)/?$ index.php?part=$1
RewriteRule ^published/([a-zA-Z0-9-]+)/category/([a-zA-Z0-9-]+)/?$ index.php?part=$1&category=$2
RewriteRule ^upcoming/([a-zA-Z0-9-]+)/category/([a-zA-Z0-9-]+)/?$ upcoming.php?part=upcoming&order=$1&category=$2
RewriteRule ^search/(.+)/?$ search.php?search=$1
RewriteRule ^searchurl/(.+)/?$ search.php?url=$1
RewriteRule ^login/?$ login.php
RewriteRule ^login/([a-zA-Z0-9-]+)/?$ login.php?return=$1
RewriteRule ^login/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ login.php?return=$1/$2
RewriteRule ^register/?$ register.php
RewriteRule ^topusers/?$ topusers.php
RewriteRule ^about/([a-zA-Z0-9-]+)/?$ faq-$1.php
RewriteRule ^upcoming/?$ upcoming.php
RewriteRule ^submit/?$ submit.php
RewriteRule ^rss/?$ rss.php
RewriteRule ^rss/([a-zA-Z0-9-]+)/?$ rss.php?status=$1
RewriteRule ^rss/category/([a-zA-Z0-9-]+)/?$ rss.php?category=$1
RewriteRule ^rss/search/([a-zA-Z0-9-]+)/?$ rss.php?search=$1
RewriteRule ^rss/user/([a-zA-Z0-9-]+)/?$ rss.php?user=$1
RewriteRule ^rss/user/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ userrss.php?user=$1&status=$2
RewriteRule ^trackback/([0-9]+)/?$ trackback.php?id=$1
RewriteRule ^profile/?$ profile.php
RewriteRule ^admin/?$ admin_index.php
RewriteRule ^tagcloud/?$ cloud.php
RewriteRule ^tagcloud/range/([0-9]+)/?$ cloud.php?range=$1 [L]
RewriteRule ^tag/(.+)/?$ search.php?search=$1&tag=true [QSA,NC,L]
RewriteRule ^live/?$ live.php
RewriteRule ^out/([^/]+)/?$ out.php?title=$1 [L]
RewriteRule ^settemplate/?$ settemplate.php
RewriteRule ^comments/?$ live_comments.php
RewriteRule ^live_published/?$ live_published.php
RewriteRule ^unpublished/?$ live_unpublished.php
RewriteRule ^logout/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ login.php?op=logout&return=$1/$2
RewriteRule ^published/page/([^/]+)/?$ index.php?page=$1 [L]
RewriteRule ^published/page/([^/]+)/category/([^/]+)/?$ index.php?page=$1&category=$2 [L]
RewriteRule ^published/page/([^/]+)/([^/]+)category/([^/]+)/?$ index.php?page=$1&part=$2&category=$3 [L]
RewriteRule ^upcoming/page/([0-9]+)/?$ upcoming.php?page=$1 [L]
RewriteRule ^upcoming/page/([^/]+)/category/([^/]+)/?$ upcoming.php?page=$1&category=$2 [L]
RewriteRule ^upcoming/page/([^/]+)/upcoming/([^/]+)/?$ upcoming.php?page=$1&part=upcoming&order=$2 [L]
RewriteRule ^upcoming/page/([^/]+)/upcoming=([^/]+)category/([^/]+)/?$ upcoming.php?page=$1&part=upcoming&order=$2&category=$3 [L]
RewriteRule ^topusers/page/([^/]+)/?$ topusers.php?page=$1 [L]
RewriteRule ^topusers/page/([^/]+)/sortby/([^/]+)?$ topusers.php?page=$1&sortby=$2 [L]
RewriteRule ^admin_links/page/([^/]+)/?$ admin_links.php?page=$1
RewriteRule ^admin_comments/page/([^/]+)/?$ admin_comments.php?page=$1
RewriteRule ^admin_users/page/([^/]+)/?$ admin_users.php?page=$1
RewriteRule ^comments/page/([^/]+)/?$ live_comments.php?page=$1 [L]
RewriteRule ^published/page/([^/]+)/?$ live_published.php?page=$1 [L]
RewriteRule ^unpublished/page/([^/]+)/?$ live_unpublished.php?page=$1 [L]
RewriteRule ^published/page/([^/]+)/([^/]+)/?$ index.php?page=$1&part=$2 [L]
RewriteRule ^published/page/([^/]+)/range/([^/]+)/?$ ?page=$1&range=$2 [L]
RewriteRule ^search/page/([^/]+)/search/([^/]+)/?$ search.php?page=$1&search=$2 [QSA,NC,L]
RewriteRule ^user/page/([^/]+)/([^/]+)/([^/]+)/?$ user.php?page=$1&view=$2&login=$3 [L]
RewriteRule ^statistics/page/([^/]+)/?$ module.php?module=pagestatistics&page=$1
RewriteRule ^view/([^/]+)/?$ admin_users.php?mode=view&user=$1
##### URL Method 2 ("Clean" URLs) End #####


As i got installed under httP://estosesale.com/news and my english knowledge is limited at least for that kind of technical issues.... I don't know if that lines detailed below are correct:
## Remove these two lines if you have a sub-domain like http://ashdigg.pligg.com or http://localhost
## Keep if your site it like http://www.pligg.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##### Re-directing End #####


2-On the other hand my utils.php file looks like that (after doing the changes suggested by you):
Code:
<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
//       http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".

function check_if_table_exists($table) {
   // checks to see if a table in the database exists
   $result = mysql_query('select * from ' . $table);
   if (!$result) {
      return false;
   }
   return true;
}

function pligg_version(){
   // returns the version of Pligg that's installed
   $ver = get_misc_data('pligg_version');
   return $ver;
}

function get_misc_data($name){
   // returns data from the misc_data table
   global $db;
   $sql = "SELECT `data` FROM `" . table_misc_data . "` WHERE `name` = '" . $name . "';";
   $var = $db->get_var($sql);
   return $var;
}

function misc_data_update($name, $data){
   // updates a row in the misc_data table
   global $db;
   $sql = "UPDATE `" . table_misc_data . "` SET `data` = '" . $data . "' WHERE `name` = '$name';";
   $db->query($sql);
}

function safeAddSlashes($string) {
   // if function get_magic_quotes_gpc exists, returns a string with backslashes before characters that need to be quoted in database queries etc
   if (get_magic_quotes_gpc()) {
      return $string;
   }
   else {
      return addslashes($string);
   }
}

function unixtimestamp($timestamp){
   if(strlen($timestamp) == 14) {
      $time = substr($timestamp,0,4)."-".substr($timestamp,4,2)."-".substr($timestamp,6,2);
      $time .= " ";
      $time .=  substr($timestamp,8,2).":".substr($timestamp,10,2).":".substr($timestamp,12,2);
      return strtotime($time);
   }
   else {
      if(strlen($timestamp) == 0) {
         return 0;
      }
      else {
         return strtotime($timestamp);
      }
   }
}

function user_exists($username) {
   // checks to see if user already exists in database
   global $db;
   $res=$db->get_var("SELECT count(*) FROM " . table_users . " WHERE user_login='$username'");
   if ($res>0) return true;
   return false;
}

function email_exists($email) {
   // checks to see if email already exists in database
   global $db;
   $res=$db->get_var("SELECT count(*) FROM " . table_users . " WHERE user_email='$email'");
   if ($res>0) return $res;
   return false;
}

function check_email($email) {
   // checks to see if email is valid
   return preg_match('/^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,4}$/', $email);
}

function check_email_address($email) {
  //from http://www.ilovejackdaniels.com/php/email-address-validation/
  // First, we check that there's one @ symbol, and that the lengths are right
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
      return false;
    }
  } 
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; // Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}

function txt_time_diff($from, $now=0){
   global $main_smarty;
   
   $txt = '';
   if($now==0) $now = time();
   $diff=$now-$from;
   $days=intval($diff/86400);
   $diff=$diff%86400;
   $hours=intval($diff/3600);
   $diff=$diff%3600;
   $minutes=intval($diff/60);

   if($days>1) $txt  .= " $days ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Days');
   else if ($days==1) $txt  .= " $days ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Day');

   if($days < 2){
      if($hours>1) $txt .= " $hours ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Hours');
      else if ($hours==1) $txt  .= " $hours ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Hour');
   
      if($hours < 3){
         if($minutes>1) $txt .= " $minutes ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Minutes');
         else if ($minutes==1) $txt  .= " $minutes ".$main_smarty->get_config_vars('PLIGG_Visual_Story_Times_Minute');
      }
   }
   
   if($txt=='') $txt = ' '. $main_smarty->get_config_vars('PLIGG_Visual_Story_Times_FewSeconds') . ' ';
   return $txt;
}

function txt_shorter($string, $len=80) {
   // shorten a string to 80 characters
   if (strlen($string) > $len)
      $string = substr($string, 0, $len-3) . "...";
   return $string;
}

function save_text_to_html($string) {
   $string = strip_tags(trim($string));
   $string= htmlspecialchars($string);
   $string= text_to_html($string);
   $string = preg_replace("/[\r\n]{2,}/", "<br /><br />\n", $string);
   return $string;
}

function text_to_html($string) {
   return preg_replace('/([hf][tps]{2,4}:\/\/[^ \t\n\r]+[^ .\t,\n\r\(\)"\'])/', '<a href="$1">$1</a>', $string);
}

function check_integer($which) {
   // checks to make sure it's an integer greater than 0
   if(isset($_REQUEST[$which])){
      if (intval($_REQUEST[$which])>0) {
         return intval($_REQUEST[$which]);
      } else {
         return false;
      }
   }
   return false;
}

function check_string($which) {
   if (!empty($_REQUEST[$which])) {
      return intval($_REQUEST[$which]);
   } else {
      return false;
   }
}

function get_current_page() {
   if(($var=check_integer('page'))) {
      return $var;
   } else {
      return 1;
   }
}


function get_date($epoch) {
   // get date in the format year-month-day
    return date("Y-m-d", $epoch);
}

function get_base_url($url){
   // get base of URL. For example, get_base_url will return www.pligg.com if the URL was www.pligg.com/forum/
   $req = $url;
 
   $pos = strpos($req, '://');
   $protocol = strtolower(substr($req, 0, $pos));
 
   $req = substr($req, $pos+3);
   $pos = strpos($req, '/');
   if($pos === false)
      $pos = strlen($req);
   $host = substr($req, 0, $pos);
   
   return $host;
}


function get_permalink($id) {
   return getmyFullurl("story", $id);
}

function get_trackback($id) {
   return getmyurl("trackback", $id);
}

function checklevel($levl){
   global $current_user;
   if(isset($current_user->user_level)){
      if ($current_user->user_level == $levl)
      {
         return 1;
      }
   }
}


function makeUrlFriendly($input) {
   global $db;

   //$input = remove_error_creating_chars($input);
   $output = utf8_strtolower($input, 0, 240);
   
   $output = trim($output);   
   $output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));

   $output = preg_replace("/\s/e" , "_" , $output);    // Replace spaces with underscores
   $output = str_replace("--", "-", $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);    
   $output = str_replace(".", "-", $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);    
   $output = str_replace(">>", "-", $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);
   $output = str_replace("[", "", $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);
   $output = str_replace("@", "", $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);
   $output = str_replace(" - ", "-", $output);
   $output = str_replace("_", "-", $output);
   $output = str_replace("---", "-", $output);
   $output = str_replace("\"", "", $output);
   $output = str_replace("--", "-", $output);
   

   if(function_exists('utils_makeUrlFriendly')) {
      $output = utils_makeUrlFriendly($output);
   }
   
   // check to see if the story title already exists. If so, add an integer to the end of the title
   $n = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_title_url like '$output%'");
   if ($n > 0) {
      return $output . "-$n";}
   else {
      return $output;
   }
}


function makeCategoryFriendly($input) {

   $input = utf8_substr($input, 0, 240);

   $output = trim($input);

   $output = preg_replace("/\s/e", "", $output);    // remove spaces
   $output = str_replace("_", "", $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);
   $output = str_replace('?', '', $output);
   $output = str_replace('$', '', $output);
   
   if(function_exists('utils_makeUrlFriendly')) {
      $output = utils_makeUrlFriendly($output);
   }
   
   return urlencode($output);      
}

function remove_error_creating_chars($chars) {
   $replace=array(
   'Á' => 'A',
   'Å' => 'A',
   'ä' => 'a',
   'á' => 'a2',
   'à' => 'a3',
   'â' => 'a4',
   'ã' => 'a5',
   'ä' => 'a',
   'å' => 'a',
   'æ' => 'ae',
   'æ' => 'ae',
   'é' => 'e',
   'È' => 'E',
   'É' => 'E',
   'Ì' => 'I',
   'ì' => 'i',
   'Í' => 'I',
   'í' => 'i',
   '¼' => '',
   '¾' => '',
   '¿' => '',
   'ñ' => 'n',
   'Ñ' => 'N',
   'Ò' => 'O',
   'ò' => 'o',
   'Ö' => 'O',
   'Õ' => 'O',
   'Ó' => 'O',
   'ô' => 'o',
   'ó' => 'o',
   'õ' => 'o',
   'ö' => 'o',
   'Š' => 's',
   'š' => 's',
   'Û' => 'U',
   'Ú' => 'U',
   'Ü' => 'U',
   'û' => 'u',
   'ú' => 'u',
   'ü' => 'u',
   'Ý' => 'Y',
   'ý' => 'y',
   'Ž' => 'Z',
   'ž' => 'z',
   '€' => ''
   );

   foreach ($replace as $key => $value) {
      $chars = str_replace($key, $value, $chars );
   }
   return $chars;
}

function loghack($page, $extradata, $silent=false){
   // This function will be used for logging hacking attempts.
   // you'd also want IP Address
   // - date / time
   // email or log to file
   if($silent == false){
      die("Hacking attempt on ". $page);
   }
}

function checkforfield($fieldname, $table) {
   // checks to see if field exists in table
   $result = mysql_query('select * from ' . $table . ' LIMIT 1');
   if (!$result) {
      echo "<HR />ERROR! The table " . $table . " is missing! Are you sure you should be doing an upgrade?<HR />";
      return true;
   }
   $i = 0;
   while ($i < mysql_num_fields($result)) {
      $meta = mysql_fetch_field($result, $i);
      if (!$meta) {
         echo "No information available<br />\n";
      }
      else {
         if(strtolower($meta->name) == strtolower($fieldname)){
            return true;
         }
      }
      $i++;
   }
   return false;
}

function object_2_array($result) {
   // using this because i'm not sure if (array)$user will work in php 4
   // i'm not sure if we even need all this but it makes my code work
      $array = array();
      if(isset($result)){
         foreach ($result as $key=>$value) {
            if (is_object($value)) {
               $array[$key]=object_2_array($value);
            }
            elseif (is_array($value)) {
               $array[$key]=object_2_array($value);
            }
            else {
               $array[$key]=$value;
            }
         }
      }
      return $array;
}

function phpnum() {
   // returns the php version number
   $version = explode('.', phpversion());
   return (int) $version[0];
}
?>


Wed Dec 26, 2007 12:32 am
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 263
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Hi,

The code you posted below

Code:
## Remove these two lines if you have a sub-domain like http://ashdigg.pligg.com or http://localhost
## Keep if your site it like http://www.pligg.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##### Re-directing End #####


Should be...

Code:
## Remove these two lines if you have a sub-domain like http://ashdigg.pligg.com or http://localhost
## Keep if your site it like http://www.pligg.com
##RewriteCond %{HTTP_HOST} !^www\.
##RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##### Re-directing End #####


if your pligg install is in a sub directory and i remember correctly :)

Your utils.php seems fine to me ;)

PS. It will only work for new URL's you submit old submitted URLS will still show the _ instead of - as the post safename is stored in the database. ;) if you edit a submission that is showing _ it should change to - after the edit or just submit a new url to your site and you should see it working


Wed Dec 26, 2007 3:08 am
Profile
juanmartinbravo

Joined: Tue Dec 25, 2007 10:47 pm
Posts: 6
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Quote:
PS. It will only work for new URL's you submit old submitted URLS will still show the _ instead of - as the post safename is stored in the database. ;) if you edit a submission that is showing _ it should change to - after the edit or just submit a new url to your site and you should see it working

Thank you very much it works now!
I really appreciate your work, it should be included on next Pligg release :)


Wed Dec 26, 2007 9:58 am
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 263
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Good to hear you got it working at last juan :)


Wed Dec 26, 2007 12:59 pm
Profile
bbrian017

Joined: Sun Jan 06, 2008 2:35 am
Posts: 33
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
I added the code, I don't see any errors but I also think I'm using URL method 1

If I switch it to method 2 will I see issues, http://www.blogengage.com Also this is a pre existing pligg 9.8.2 website!

EDIT: Ok I said url 2 method and I got page not found but I'm assuming it's because the url wasn't created yet or doesn't exist. How do I go about making it so the url is there using SEO and Method 2.

Do I need to also do the above suggestion ?

_________________
Search Engine | Social Networking for Bloggers | Better Affiliate Marketing | More Affiliate Marketing


Sun Jan 06, 2008 2:53 am
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 263
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
bbrian017 wrote:
I added the code, I don't see any errors but I also think I'm using URL method 1

If I switch it to method 2 will I see issues, http://www.blogengage.com Also this is a pre existing pligg 9.8.2 website!

EDIT: Ok I said url 2 method and I got page not found but I'm assuming it's because the url wasn't created yet or doesn't exist. How do I go about making it so the url is there using SEO and Method 2.

Do I need to also do the above suggestion ?


Hi bbrian,

I see you have used URL method 1 to begin with on your site

Code:
http://www.blogengage.com/story.php?title=The_IWH_Inquirer_Skin_Deep_a_breakthrough_for_Pluripotent_stem_cells


the part of the url that says

Code:
The_IWH_Inquirer_Skin_Deep_a_breakthrough_for_Pluripotent_stem_cells


is stored in the pligg database field link_title_url at the moment and this is where pligg fetches is safe URL structure from, therefore old urls even with this mod applied will still read _ instead of - as the information was submitted using the old structure before the mod was applied.

A possible fix for this off the top of my head is to run a MYSQL query from phpMyAdmin that will affect the pligg_links table and the link_title_url field converting _ to -, best person to as is Ashdigg master of all things pligg on that one dude if it's even possible.

Hope that helps man


Sun Jan 06, 2008 3:18 am
Profile
bbrian017

Joined: Sun Jan 06, 2008 2:35 am
Posts: 33
Post Re: Pligg Google SEO Friendly URL Rewrite Hack
Thanks for the information. I don't think I'm ready for a change like that. :) I wish I could get it done! Right now Google is in my Top 3 traffic generating websites. Anything to get more is always wanted :)

Cool that you're using phpbb :) I support and love open source software !

_________________
Search Engine | Social Networking for Bloggers | Better Affiliate Marketing | More Affiliate Marketing


Sun Jan 06, 2008 4:38 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 2
 [ 17 posts ]  Go to page 1, 2  Next

Board index » Pligg » Pligg Marketing and SEO » SEO Hacks

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

©2007-2008 Social CMS Buzz

Feed XML Favourite Valid XHTML Valid CSS WordPress