Welcome to WebmasterWorld Guest from 54.144.243.34

Redirecting example.com/index.php to example.com

Google thinks they are separate pages

   
3:03 am on Sep 14, 2006 (gmt 0)

10+ Year Member



It seems that google treats www.wexample.com and www.example.com/index.php as two separate entities. One has PR5 and the other has PR4. Does anybody know how can i effectively redirect index.php to the root(www.example.com)?

[edited by: tedster at 4:14 am (utc) on Sep. 14, 2006]
[edit reason] use example.com [/edit]

4:30 am on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You're correct that these are two different URLs and if both are indexed in Google you can get "split PR".

Assuming you are on an Apache server, here's a thread with a Rewrite solution [webmasterworld.com] from jdMorgan that you can use in your .htaccess file:

# mod_rewrite setup
Options +FollowSymLinks
RewriteEngine on
#
# Redirect direct client /index.html requests to "/" (does not affect DirectoryIndex accesses)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html
RewriteRule ^index\.html$ http://example.com/ [R=301,L]
3:15 pm on Sep 15, 2006 (gmt 0)

5+ Year Member



Tedster,

Is this also a possibility on IIS? I have a site where both http://www.example.com/default.aspx and http://www.example.com/ are listed.
The problem is that IIS adds the default.aspx automatically as the defaukt document, otherwise it does not know where the results from http://www.example.com/ are supposed to come from.
I cannot find any difference in the request header or content between the requests for both pages.

4:41 pm on Sep 15, 2006 (gmt 0)

5+ Year Member



It looks is working fine to me in this way:

<?php
if(strstr($_SERVER["REQUEST_URI"],"index.php"))
{
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header("location:./");
exit();

7:23 pm on Sep 16, 2006 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



For IIS it is even worse, you have yet more duplicates at /Default.asp and /default.ASP and many others, etc.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month