Pligg Tutorial: How to Remove the word category from Pligg’s category URL’s

pligg_seo.thumbnail.gifThis article could be considered a continuation of an article i wrote titled “Optimize your pligg site for better SEO with these guide tutorial instructions“, in that article i covered hypens vs underscores within pligg’s URL structure and supplied the code changes titled “Pligg Google SEO Friendly URL Rewrite Hack” along with my “Pligg Optimal Page Titles Hack” and “Pligg XML Google Sitemaps“. As you can tell from the content of the article i like SEO for Pligg and this article is no different as i show you how to optimize your pligg category url’s for a better SEO’d solution.


This article was born out of a comment on our blog posted by anil in response to the Pligg SEO article i wrote.

anil Says:
Hello guys,

Have a site am using 2nd method url in pligg and the prob is
http://www.jeqq.com/category/news_technology_Apple

its should be like ths
http://www.jeqq.com/category/news/technology/Apple

or

like digg

http://www.digg.com/apple

But some of the devs told me its not possbile…will that effect my google rankings…

After reading anil’s comment it got me thinking why the word “category” was present within the url to beign with? which then led me onto trying to figure out a possible solution. So is this possible, the answer is yes. Will it affect your rankings in a bad way, the answer is no as long as you 301 redirect your old category url’s to the newly optimiized ones. Will it boost your rankings in search engine, i really cannot say for sure but it certainly won’t do any harm.

The first thing you need to know is that this pligg hack requires some code changes to the pligg codebase, i used v9.9.0 as our testing base.

Lets Begin

I will start off by explaining what this hack will acheive by showing an example of before and after :.

Original Published Category URL
http://yoursite.com/category/WorldNews

Optimized Published Categroy URL
http://yoursite.com/WorldNews

Original Upcoming Category URL
http://yoursite.com/upcoming/category/WorldNews

Optimized Upcoming Categroy URL
http://yoursite.com/upcoming/WorldNews

Sorts Bar url’s “Sort by:” are also affected

Original Sorts Published Category URL
http://yoursite.com/published/recent/category/WorldNews

Optimized Sorts Published Categroy URL
http://yoursite.com/published/recent/WorldNews

Original Upcoming Category URL
http://yoursite.com/upcoming/newest/category/WorldNews

Optimized Upcoming Categroy URL
http://yoursite.com/upcoming/newest/WorldNews

What You Will Need

1. Around 30mins to 1 hour of time to perform the code changes and test depending on experience.
2. Knowledge of how to 301 redirect URL’s with .htaccess if your pligg site is already live.
3. a computer haha

Code Changes

OPEN libs/html1.php

FIND


If ($x == "maincategory") {return my_pligg_base."/category/" . $var1;}
If ($x == "queuedcategory") {return my_pligg_base."/upcoming/category/" . $var1;}
If ($x == "discardedcategory") {return my_pligg_base."/discarded/category/" . $var1;}

REPLACE WITH


If ($x == "maincategory") {return my_pligg_base."/" . $var1;}
If ($x == "queuedcategory") {return my_pligg_base."/upcoming/" . $var1;}
If ($x == "discardedcategory") {return my_pligg_base."/discarded/" . $var1;}

OPEN libs/smartyvariables.php

FIND


$main_smarty->assign('index_url_recent', getmyurl('index_sort', 'recent', 'category/'.$_GET['category']));
$main_smarty->assign('index_url_today', getmyurl('index_sort', 'today', 'category/'.$_GET['category']));
$main_smarty->assign('index_url_yesterday', getmyurl('index_sort', 'yesterday', 'category/'.$_GET['category']));
$main_smarty->assign('index_url_week', getmyurl('index_sort', 'week', 'category/'.$_GET['category']));
$main_smarty->assign('index_url_month', getmyurl('index_sort', 'month', 'category/'.$_GET['category']));
$main_smarty->assign('index_url_year', getmyurl('index_sort', 'year', 'category/'.$_GET['category']));
$main_smarty->assign('cat_url', getmyurl("maincategory"));

REPLACE WITH


$main_smarty->assign('index_url_recent', getmyurl('index_sort', 'recent/'.$_GET['category']));
$main_smarty->assign('index_url_today', getmyurl('index_sort', 'today/'.$_GET['category']));
$main_smarty->assign('index_url_yesterday', getmyurl('index_sort', 'yesterday/'.$_GET['category']));
$main_smarty->assign('index_url_week', getmyurl('index_sort', 'week/'.$_GET['category']));
$main_smarty->assign('index_url_month', getmyurl('index_sort', 'month/'.$_GET['category']));
$main_smarty->assign('index_url_year', getmyurl('index_sort', 'year/'.$_GET['category']));
$main_smarty->assign('cat_url', getmyurl("maincategory"));

OPEN /upcoming.php

FIND


$main_smarty->assign('upcoming_url_newest', getmyurl('upcoming_sort', 'newest', 'category/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_oldest', getmyurl('upcoming_sort', 'oldest', 'category/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_mostpopular', getmyurl('upcoming_sort', 'mostpopular', 'category/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_leastpopular', getmyurl('upcoming_sort', 'leastpopular', 'category/'.sanitize($_GET['category'],2)));< $main_smarty->assign('cat_url', getmyurl("queuedcategory"));

REPLACE WITH


$main_smarty->assign('upcoming_url_newest', getmyurl('upcoming_sort', 'newest/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_oldest', getmyurl('upcoming_sort', 'oldest/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_mostpopular', getmyurl('upcoming_sort', 'mostpopular/'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_leastpopular', getmyurl('upcoming_sort', 'leastpopular/'.sanitize($_GET['category'],2)));
$main_smarty->assign('cat_url', getmyurl("queuedcategory"));

OPEN .htaccess

FIND


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/

BELOW ADD


RewriteRule ^story/([0-9]+)/?$ story.php?id=$1 [L]
RewriteRule ^story/title/([a-zA-Z0-9-]+)/?$ story.php?title=$1 [L]
RewriteRule ^category/([^/]+)/?$ index.php?category=$1 [L]
RewriteRule ^upcoming/([^/]+)/?$ upcoming.php?category=$1 [L]
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∂=$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∂=upcoming&order=$2 [L]
RewriteRule ^upcoming/page/([^/]+)/upcoming=([^/]+)category/([^/]+)/?$ upcoming.php?page=$1∂=upcoming&order=$2&category=$3 [L]

That should be all the edits completed, clear your /cache and /templates_c folders and try it out.

Feel free to comment and for support please visit the forum topic How to Remove the word category from Pligg’s category URL’s

If you enjoyed this post, make sure you subscribe to my RSS feed!

Article Details

#

Author: on January 20th, 2008

Category: Pligg Tutorials

Tags: , , , ,

  1. Alexander says:

    I use pligg 1.00 RC2. I get the following path:
    http://www.dailytalk.com/Internet

    But instead of showing the page I get the following message:
    The page you were looking for doesn’t exist!

  2. Digaki says:

    I like to modify the Pagination also enter in a category where?

  3. muky says:

    Hi,
    i Need your help. i want to add numbers to my pligg story url
    http://mysite.com/story/help-nedded
    and i want to convert it into

    http://sphinn.com/story/help-nedded-1308 (1308 post counter)
    can u plz send me the code how to do it i am using pligg latest version. i am ready to pay for this.
    Plz reply me on my email bazarapna_biz@yahoo.com

    Thanks