If they are the same, then there might be a bug in the login code that does this, and it might be causing the redirect loop. If they are different (even slightly, like one not fully-qualified) then that might be the reason for the redirect.