WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Search Engines > Other Engines/Directories
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Other Engines/Directories Got a comment about directories or some other engine? This is the place. There is a subforum dedicated to directories.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2006, 08:10 AM
WebProWorld New Member
 

Join Date: Oct 2005
Posts: 23
ashishdabas RepRank 0
Default Can 301 redirect make a page to go in an infinite loop?

Thanks for the reply to my earlier post.

Earlier I asked the same question about 301 redirection (pls see earlier post for details: http://www.webproworld.com/viewtopic.php?t=64012) to one of my seniors in our office, and following was his reply:

"The default page for http://www.my-medicare.com is index.php so if you type site name with or without index.php it will going to call index.php itself. The solution of redirection won't work because it will get a infinte loop of page calling and the page won't load."

Will it get in an infinite loop of page calling? Neither I understood it nor I was agreed with him. So I had to post it here.

I sent him the following codes used for redirecting? (Kindly check these codes if these will work fine or some changes are required, pls send me the changes if there is any)

301 redirect using .htaccess:
-----------------------------

redirect 301 /index.php http://www.my-medicare.com
(without using 'http://www' in first url)

The .htaccess file would then be uploaded to the same location where we have uploaded the index page at our OLD domain that we are redirecting from.

OR

301 Redirect using PHP (by simply adding this code to the page):
---------------------------------------------
<?
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.new-url.com/" );
?>

Please tell me how this problem can be solved?

Waiting for a reply!!!

Thanks,
Ashish
Reply With Quote
  #2 (permalink)  
Old 05-30-2006, 05:35 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,330
jestep RepRank 0
Default

Quote:
Will it get in an infinite loop of page calling? Neither I understood it nor I was agreed with him. So I had to post it here.
Yes it will create an infinite loop.

If you echo a $PHP_SELF from the root page on a website, you will see index.php. If you try to redirect from index.php to the root (IE: http://www.mysite.com/index.php -> http://www.mysite.com/), you are redirecting back to the same page, thereby redirecting again, and creating an infinite loop.

The easiest way to solve the problem is to never link to the index.php page, and block it with robots.txt. Search engines still see index.php and the root as different pages even though your server doesn't. Because of this they will index the root and not the index.php page.

There is probably another server side method of fixing it, but I have always used the robots way and haven't had any problems.
Reply With Quote
  #3 (permalink)  
Old 05-30-2006, 06:20 PM
brian.mark's Avatar
Administrator
 

Join Date: Jul 2004
Location: Omaha
Posts: 2,717
brian.mark RepRank 2brian.mark RepRank 2
Default

Quote:
Originally Posted by jestep
Quote:
Will it get in an infinite loop of page calling? Neither I understood it nor I was agreed with him. So I had to post it here.
Yes it will create an infinite loop.

If you echo a $PHP_SELF from the root page on a website, you will see index.php. If you try to redirect from index.php to the root (IE: http://www.mysite.com/index.php -> http://www.mysite.com/), you are redirecting back to the same page, thereby redirecting again, and creating an infinite loop.

The easiest way to solve the problem is to never link to the index.php page, and block it with robots.txt. Search engines still see index.php and the root as different pages even though your server doesn't. Because of this they will index the root and not the index.php page.

There is probably another server side method of fixing it, but I have always used the robots way and haven't had any problems.
I'll totally agree with that here. I just tried it on one of our sites and saw the infinite loop issue come up, so it does indeed do that.

If you want to do so, you're going to need to use the REQUEST_URI environment variable to do the redirect. Look for index.php at the end, and if it exists do the redirect via the PHP method listed above. If it doesn't exist, then just let it go.

If you prefer .htaccess, it's possible using ModRewrite.

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*domain.com/index.php$
RewriteRule ^index.php http://www.domain.com/ [R=301]
That will handle a 301 from index.php to / without the looping. (Make sure you use request_uri - that's an i and not an L. I've seen that messed up quite often.)

Brian.
__________________
ToolBarn.com, an Internet Retailer Top 500 and Inc. 500 Company | Tool Parts | Pet Supplies
Reply With Quote
  #4 (permalink)  
Old 05-30-2006, 09:59 PM
DrTandem1's Avatar
WebProWorld 1,000+ Club
 

Join Date: Oct 2003
Location: Encinitas, CA
Posts: 1,908
DrTandem1 RepRank 2
Default

I think the reason you are attempting to redirect is to increase PR and/or ranking (from what you asked in your original question in the other thread). I don't think this will have any positive effect and redirecting almost always causes an initial loss of both with regards to Google.

Although, 301 redirects are the way to go, it is (in my opinion) best to avoid a redirect, if at all possible.
__________________
DrTandem's San Diego Web Page Design, drtandem.com
Reply With Quote
  #5 (permalink)  
Old 05-31-2006, 01:18 AM
WebProWorld New Member
 

Join Date: Oct 2005
Posts: 23
ashishdabas RepRank 0
Default 301 redirect problem?

Thank you very much all of you for giving me such a useful help. Hope if I have any other query in future I will get the same support from all of you there.

Thanks a lot again.

Ashish
Reply With Quote
Reply

  WebProWorld > Search Engines > Other Engines/Directories
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0