homepage Welcome to WebmasterWorld Guest from 54.204.94.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
301 Redirect error
"Redirection limit exceeded"
superbird

10+ Year Member



 
Msg#: 10354 posted 10:56 am on Jun 8, 2005 (gmt 0)

I've done a redirect in a .htaccess using

"redirect 301 / [sub.example.com...]

and Firefox is giving me an error message saying:

"Redirection limit for this URL exceeded. Unable to load the requested page. This maybe caused by cookies that are blocked"

I've tried allowing all cookies but it makes no difference. Both addresses are in the same subdomain of the same TLD.

Any ideas?

 

RonPK

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10354 posted 2:06 pm on Jun 8, 2005 (gmt 0)

Sounds like an infinite loop. Are you sure that the target of the redirect doesn't point to itself?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 10354 posted 2:21 pm on Jun 8, 2005 (gmt 0)

To expand on the previous post, because it is unconditional, your Redirect will also be invoked for the redirected request, leading to a loop:

1st request: /somefile -> redirects to /folder/somefile
2nd request: /folder/somefile -> redirects to /folder/folder/somefile
3rd request: /folder/folder/somefile -> redirects to /folder/folder/folder/somefile

etc. This continues until the maximum redirection limit for either the browser or the server is reached, whichever is lower.

If you have sufficient permissions from your host to use mod_rewrite [httpd.apache.org] in .htaccess, then you can test the requested folder, and only redirect if "/folder" is not present in the request. This will prevent the looping. Something like:

Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^folder/
RewriteRule (.*) /folder/$1 [L]

This code also generates a server-internal rewrite rather than an external redirect, hiding the location change from users and robots.

Jim

superbird

10+ Year Member



 
Msg#: 10354 posted 2:26 pm on Jun 8, 2005 (gmt 0)

OK, that sounds likely, because I don't know what I'm doing with this stuff yet. I'll probably draw myself a diagram to make it clearer.

Thanks guys!

superbird

10+ Year Member



 
Msg#: 10354 posted 3:07 pm on Jun 9, 2005 (gmt 0)

I still don't know what I'm doing with this :(

I've got sub.mydomain.com which I want to go to sub.mydomain.com/dir/

The host lets me do mod_rewrite but I've only ever used it with the automatic thing in WordPress, so if I try that it'll probably mess up as well

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved