Posted: 12/10/2009 08:55 PM

Member profile URL improvement 1min mod!

This mod will fix all member profiles, so that if a member has a username:
UnluckyInLove
 
their url on your site would be yoursite.com/UnluckyInLove/
but sometimes may be references places internally in vld as yoursite.com/member/98/ (where 98 is their member id)
 
This mod will help with seo rankings when members link to their profile like:
http://www.yoursite.com/unluckyinlove
or
HTTP://WWW.YOURSITE.COM/UNLUCKYINLOVE
or
http://www.yoursite.com/member/98/
 
Despite the "case" etc all these profiles URLs will currently resolve and show the correct profile (UnluckyInLove) - which is great, However for search engines who may crawl these links all of a sudden you will have a duplicate content problem. As search engines treat pages as case sensitive. Each variation of case after the domain is considered another page.
 
This simple mod solves this. (backup before any mod)
In lib.member_profile.php:
 
After:
$profile_obj = get_members_details($id, 1);
 
Add:
if ( $PREFS->conf['fancy_urls'] && $id != $profile_obj['member_username'] ) redirect(VIR_PATH . $profile_obj['member_username'] . "/" );
 
Now to make vld redirect SEO friendly.
 
In fns.misc.php:
Find the function redirect($url, $request_uri = 0) (should be at the top)
 
JUST above (important):
header("location: $url");
 
Add:
header ('HTTP/1.1 301 Moved Permanently');
 
So it should look like:
 
Text

//------------------------------------------------
// Redirect user
//------------------------------------------------
function redirect($url, $request_uri = 0)
{
        if ( $request_uri && isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] && isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] ) {
                $_SESSION['REQUEST_URI'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        }
        header ('HTTP/1.1 301 Moved Permanently');
        header("location: $url");
        exit;
}
// End function
 

Now the spiders will like the redirect, and spiders and all users who go to an incorrect "case" version of the link will be quickly redirected to the correct case. This doesn't improve usability, and would be mostly unnoticed to users, but it goes towards eliminating the chance of having duplicate member profiles that search engines hate.
 
So now:
http://www.yoursite.com/unluckyinlove
or
HTTP://WWW.YOURSITE.COM/UNLUCKYINLOVE
or
etc, etc, etc of all case variations
or
http://www.yoursite.com/member/98/
 
will all 301 redirect to the correct version:
http://www.yoursite.com/UnluckyInLove/
 
Of course if this member created their profile as
UNLUCKYINLOVE
All case variations will redirect to:
http://www.yoursite.com/UNLUCKYINLOVE/
Current mood:
264 4 2 seo, url, member profiles

Comments

by Garry 07/26/2010 04:01 AM
Thanks :) Just added to my 2.5.6 install.
by db3204 12/11/2009 08:05 AM
ok...got it....thanks
by idealists 12/11/2009 05:33 AM
Yes:
http://www.vldcrowd.com/db3204/ is the correct profile URL
 
Also the following is technically correct ( it will load your profile ), although it is all UPPER case:
http://www.vldcrowd.com/DB3204/
 
Also the following is technically correct ( it will load your profile ), although it is all MixEd case:
http://www.vldcrowd.com/Db3204/
 
My mod will SEO friendly redirect the later two, to the one which is most correct - the first. The first one is the same "case" as when you joined and entered your username.
 
This mod just prevents the possibility of having duplicated pages indexed by the search engine .
Currently if you linked to your vldcrowd profile in a post somewhere, like:
http://www.vldcrowd.com/DB3204/
The search engines would consider this to be a different page to your regular profile page that is linked to in vldcrowd everywhere as http://www.vldcrowd.com/db3204/ (because you originally typed in lower case)
 
Hope this makes more sense.
by db3204 12/11/2009 04:48 AM
Hey Idealists
 
I'm trying to follow but I'm not quite getting your meaning.
 
My site displays URLs just like vldCrowd. For example, if you click an icon image under Latest Visitors on vldCrowd, the URL looks like this: http://www.vldcrowd.com/db3204/
 
Isn't that the correct URL, even for search engines?
Add Comment


You have 1500 characters left We would not recommend you trying hard while expressing your opinion because you are not signed in and comment will not be saved.

Latest visitors

misulicus godyn gugu
johnwh antoniopuntieri WaterSpirit
dael24 delpho Like_Geo

idealists's RSS

Subscribe to idealists's Blog  RSS