• 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


How to Remove the word category from Pligg's category URL's



Post new topic Reply to topic  Page 1 of 2
 [ 15 posts ]  Go to page 1, 2  Next
Print view Previous topic | Next topic 
 How to Remove the word category from Pligg's category URL's 
Author Message
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 293
Post How to Remove the word category from Pligg's category URL's
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

Code:
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

Code:
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

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


BELOW ADD
Code:
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&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]


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


Sun Jan 20, 2008 12:23 am
Profile
JaredBlake1
User avatar

Joined: Mon Feb 04, 2008 3:38 pm
Posts: 5
Post Re: How to Remove the word category from Pligg's category URL's
Lincoln, I have the following 5 categories that include the ampersand:
arts & crafts
food & drink
home & garden
pets & animals
weird & odd

example URL: http://www.whamx.com/home_garden/
I'm not liking the underscore, can I fix this?

Also I have:
internet marketing
web 2.0

example URL: http://www.whamx.com/internetmarketing/
I'm thinking there should be a hyphen between internet-marketing?
Can I make this adjustment?

Thanks for all your help!

Regards, Jared Blake
http://www.whamx.com


Fri Feb 08, 2008 8:07 am
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 293
Post Re: How to Remove the word category from Pligg's category URL's
Hi Jared,

Try this,

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);
}


That should work, at least on v9.9.0 it seemed to 8-)


Fri Feb 08, 2008 12:42 pm
Profile
JaredBlake1
User avatar

Joined: Mon Feb 04, 2008 3:38 pm
Posts: 5
Post Re: How to Remove the word category from Pligg's category URL's
Lincoln, that worked great!!! AWESOME......... :lol:

Do you think the following tag URL's indexed by Google looks ok?

http://www.whamx.com/tag/skin+care
http://www.whamx.com/tag/find+my+flight

On multiple tag phrases the system creates the URL with the plus (+) I kinda think the hyphen (-) should be there instead? What do you think?

Update...I just looked on Google using - site:www.propeller.com.....It looks like the + may be the common way to do tags. http://www.propeller.com/tag/term+life+insurance+exams

Another udate...I just looked at my blog and the tag URL looks like this:
http://www.gojdhl.com/seo-blog/tag/social-news-site/

Lincoln, maybe we could go hyphens, let me know what you think?

Also I was trying to use 301 redirects to save those handful of URL's that were indexed prior to this change on Google. But when I did the site would just give me an error. Not critical because I decided to just throw them into robots.txt and disallow them.

Thanks again!!!


Sat Feb 09, 2008 6:45 am
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 293
Post Re: How to Remove the word category from Pligg's category URL's
Hi Jared,

Been working on his one, quite a few edits are required to cover all tags, also i dont know if or how it will affect searches till i do some further testing. ;)


Mon Feb 18, 2008 12:02 am
Profile
anilrgowda

Joined: Sat Feb 16, 2008 9:06 pm
Posts: 4
Post Re: How to Remove the word category from Pligg's category URL's
its really a cool hack...
but i tried in my site.i get ths
Oops, what you're looking for isn't here!

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.

but in upcoming it wrks fine..i guess it might be a problem of more sub categories...

the url is
http://www.jeqq.com/upcoming/category/news


Wed Feb 20, 2008 6:24 am
Profile
movvbuzz
User avatar

Joined: Thu Mar 06, 2008 1:22 am
Posts: 11
Post Re: How to Remove the word category from Pligg's category URL's
Does anyone have a code sample of how to do the 301 redirect?

_________________
http://www.movvbuzz.com


Thu Mar 06, 2008 6:41 pm
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 293
Post Re: How to Remove the word category from Pligg's category URL's
1. Always be sure to upload .htaccess files in ascii mode, sending it up as binary will break it (and usually make your server very, very unhappy.)
2. .htaccess does not work if you're on a windows server.
3. Make sure you triple check your changes. Clear your cache and look, test the server headers to make sure you see a 301 (that means its permanent) not a 302 (temporary) unless you are absolutely sure you really mean temporary.
4. Since some operating systems don't allow you to make a file without something before the "." you may need to save it as something.htaccess, some may even have to save it as htaccess.txt and change it once you've uploaded it.
5. Make sure your ftp program will show .htaccess files (FileZilla does and is free) It is a bit hard to edit something you can't see ;)
6. Double check that you're not overwriting an old one (some servers already place one there for your custom 404 pages etc.)
7. Make sure you replace example.com with your own sites URL ;-)

Code:
Redirect 301 /oldpage.html http://www.example.com/newpage.html


Fri Mar 07, 2008 4:09 pm
Profile
movvbuzz
User avatar

Joined: Thu Mar 06, 2008 1:22 am
Posts: 11
Post Re: How to Remove the word category from Pligg's category URL's
I'm not sure if my problem is related to removing the category from url's, but using google's webmaster tools I get a list of about 96 (so far) URLs that the Googlebot got a 404 (not found) on.

Here are the URLs that the googlebot is getting 404's on:
/published/month
/published/recent
/published/today
/published/week
/published/year
/search
/upcoming/leastpopular
/upcoming/mostpopular
/upcoming/oldest
So any url containing those above returned a 404. Here is a couple of exact examples for reference:
http://www.movvbuzz.com/published/recent/Trailers/
http://www.movvbuzz.com/search/anime%2F1204261994%2F

I have added the following to my robots.txt to disallow until I figure out the problem;
Code:
Disallow: /discarded
Disallow: /published/month
Disallow: /published/recent
Disallow: /published/today
Disallow: /published/week
Disallow: /published/year
Disallow: /search
Disallow: /upcoming/leastpopular
Disallow: /upcoming/mostpopular
Disallow: /upcoming/oldest


Is it a bad idea to leave these in the robot.txt? Does anyone have any ideas?
Thanks in advance for any help.

_________________
http://www.movvbuzz.com


Wed Mar 12, 2008 6:40 pm
Profile
LincolnHawks
Site Admin
User avatar

Joined: Wed Dec 12, 2007 9:34 pm
Posts: 293
Post Re: How to Remove the word category from Pligg's category URL's
Hi dude thanks for the tipoff and added to me todo list, i will take a look when i get a moment. ;)


Mon Mar 17, 2008 2:57 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 2
 [ 15 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