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/index.html" . $var1;}
If ($x == "queuedcategory") {return my_pligg_base."/upcoming/category/index.html" . $var1;}
If ($x == "discardedcategory") {return my_pligg_base."/discarded/category/index.html" . $var1;}

REPLACE WITH


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

OPEN libs/smartyvariables.php

FIND


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

REPLACE WITH


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

OPEN /upcoming.php

FIND


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

REPLACE WITH


$main_smarty->assign('upcoming_url_newest', getmyurl('upcoming_sort', '/pligg_tutorial_how_to_remove_the_word_category_from_pliggs_category_urls_20012008/comment_page_1/newest/index.html'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_oldest', getmyurl('upcoming_sort', '/pligg_tutorial_how_to_remove_the_word_category_from_pliggs_category_urls_20012008/comment_page_1/oldest/index.html'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_mostpopular', getmyurl('upcoming_sort', '/pligg_tutorial_how_to_remove_the_word_category_from_pliggs_category_urls_20012008/comment_page_1/mostpopular/index.html'.sanitize($_GET['category'],2)));
$main_smarty->assign('upcoming_url_leastpopular', getmyurl('upcoming_sort', '/pligg_tutorial_how_to_remove_the_word_category_from_pliggs_category_urls_20012008/comment_page_1/leastpopular/index.html'.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 our RSS feed!

Article Details

#

Author: Lincoln on January 20th, 2008

Category: Pligg Tutorials

Tags: , , , ,

  1. Unknown says:

    Hi, it’s me Unknown from the Pligg Forums.

    I love all the modifications you’re giving us. Thanks!

    Now about this modification, I can’t seem to find this in the file smartyvariables.php:

    $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”));

    I looked for this in other files, but also with no results. I am using the latest 9.9 version. Could you please recheck all the modifications that needs to be done, because I would love to implement this in my upcoming site.

    Thanks Again and keep it up! :)

  2. Geoserv says:

    Works like a charm. This will be a fantastic improvement to Pligg. Took about 5 minutes to do.

  3. LincolnHawks says:

    Hi Unknown,

    It should have said upcoming.php :( hehe my fault for being tired when i posted. I also added to the .htaccess for pagination to work.

    Cheers for the tipoff, Lincoln

  4. Andy says:

    Cheers for this…

    Worked it out in ten minutes and got it working… however…

    I wanted to redirect from my old categories using .htaccess rewrite.

    So I entered the commands such as…

    Redirect /category/alternativehistory http://www.historynexus.net/alternativehistory
    Redirect /category/ancienthistory http://www.historynexus.net/ancienthistory
    Redirect /category/archiveandreference http://www.historynexus.net/archiveandreference

    All well and good expect that it makes url’s like below:

    http://www.historynexus.net/alternativehistory?category=alternativehistory

    Whereas it should just read:

    http://www.historynexus.net/alternativehistory

    And here’s the weird bit that I discovered by accident. If you wrongly place in a url such as

    http://www.historynexus.net//category/alternativehistory

    (notice the double trailing slash) it works!

    I’m sure there is a simple solution to this but right now I’m tired and I’m going to bed :)

  5. Phil says:

    Hello, thanks a lot for this great tutorial! Everything is working fine except for one thing. I have some categories with accents in them and when I try to view them in the main page, I get a 404 error. They work fine in the upcoming pages though.

    This works fine:
    http://tomateo.com/upcoming/Actualit

  6. Ruel says:

    I follow the instruction but did not work in my new site. i don’t know what is the possible problem.

  7. Darren says:

    on libs/html1.php, u missed one ‘}’ in the replacement codes.

    I have tested the codes on 9.9.5, and its working great.

    Thanks for the share!

  8. Lincoln says:

    Thanks for the tipoff Darren, and that wouldn’t have helped anyone me missing the closing } i will apply the fix to the tutorial above;)

  9. Apnastory says:

    Try searching for the story you’re looking for.
    Go to the homepage to see the most recent stories.
    Browse the topics to find the story.

    Pretty sure it’s a website bug? Please let us know and we’ll try to get it fixed.

    ***Now showing this error message, Not showing any story. But Title is ok
    http://www.apnastory.com/News/………………..

  1. Pligg Tutorial: How to Remove the word category from Pligg
  2. socialcmsbuzz.com
  3. How to Remove the word category from Pligg’s category URL’s | Pliggs
  4. category - DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums
  5. pligg.com
  6. SEO tips

Leave a Reply