Unfortunately, the concept of "index" pages (index.php, Default.asp, etc.), a feature since the beginning of time on the web, causes yet another duplicate content problem. If no file name in a directory is provided to a webserver, the "index" page is typically provided by default, but without redirection. The problem arises when both URLs are linked, either internally or from other sites. Bang - duplicate content. Strictly speaking, neither URL is more correct, though shorter URLs are usually desirable, and hence "/" is favored over "/index.php." The word "index.php" really doesn't add any useful information anyway.
This is a similar problem to the www.domain.com vs domain.com issue, and though Google resolved to fix both issues with the "BigDaddy" update, it is still an issue (though perhaps less of one), and I will show here how to remove this ambiguity entirely.
This sample code shows how to use a function "assertProperURL()" in coordination with a global variable (somewhere in your header or config file, hopefully) that stores the site's main domain URL. This can also be used to assert that any page has a certain URL in order to correct them.
<?php
// NOTE:no trailing /
$GLOBALS['site_base_url'] = 'http://www.foo.com';
function assertProperURL($proper_url)
{
global $site_base_url;
$request_uri = $_SERVER['REQUEST_URI'];
$current_url = $site_base_url . $request_uri;
if ($current_url != $proper_url) {
header("HTTP/1.1 301 Moved Permanently");
header('Location: ' . $proper_url);
}
}
assertProperURL($GLOBALS['site_base_url'] . '/', true);
?>
As a test, try to access http://www.lawyerseek.com/index.php; I dare you :)











