Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

How to 301 Redirect for SEO purposes, maximizing link juice to every page

Dawn Rossi, 09-19-2008
To maximize your website pages link juice, there are a few simple rules you have to follow:

#1. Avoid session variables in your urls

This is bad: http://www.mydomain.com/?PHPSESSID=1234567

#2. Avoid duplicate content

If you're using clean urls, category pages (WordPress, vBulletin, Joomla) or tags, you will end up with multiple copies of the same content with different urls:

http://www.mydomain.com/showthread.php?id=12345
http://www.mydomain.com/clean_thread_name-t12345.html
http://www.mydomain.com/?id=12345
http://www.mydomain.com/index.php

Where all four versions are pointing to the exact same page.

=

To fix this, you have to "301 redirect" to a single clean version of each page.

301 redirect is the act of telling search engines, your page permanently moved to a new address, keeping all link juice flowing to a single place.

Here's how:

At the top of every display script, fetch the current clean-url for that page and if that doesn't match REQUEST_URI, redirect the user to the clean version:


// For SEO purposes, 301 redirect if url
// is not what it needs to be
{
   
// Get clean url for this page
   
$clean_url = GetCleanThreadURL($forumid, $threadid);
   
$current_url_noparams = $REQUEST_URI;
    if ((
$pos = strpos($current_url_noparams,"?"))!==false)
    {
       
$current_url_noparams = substr($current_url_noparams,0,$pos);
    }
   
// If we have a session ID, or current_no_params doesn't match clean url
   
if (strpos($REQUEST_URI, "PHPSESSID")!==false ||
   
Strcasecmp($current_url_noparams, $clean_rul)!=0)
    {
       
// Redirect user to clean url
       
Header( "HTTP/1.1 301 Moved Permanently" );
       
Header( "Location: $clean_url");
        return;
    }
}
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions