ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

301 Redirects Result in Endless Loop

May 27, 2011 1:23pm

Subscribe [2]
  • #1 / May 27, 2011 1:23pm

    Unifusion

    103 posts

    Hello,

    I’ve been setting up some 301 redirects for my client’s site and something strange happened. If I redirect the client’s old pages called “index.html” and “home.html” to the new EE site homepage, the browser throws an “Endless Loop” error. Any other pages I redirect work fine. I don’t understand what the problem is - is there some setting in EE that might cause this?

    I have the Structure module installed, and the homepage URL is “home” - could that have something to do with the “home.html” part of the problem?

    Thanks!

    [Mod Edit: Moved to the Community Help forum]

  • #2 / May 27, 2011 2:30pm

    See what they have to say on the support forums for Structure.

  • #3 / May 27, 2011 2:32pm

    Unifusion

    103 posts

    But I don’t know that it’s necessarily a Structure problem - seeing as “index.html” has nothing to do with Structure.

  • #4 / May 27, 2011 2:38pm

    Good point; how are you setting up the 301s?  .htaccess?

  • #5 / May 27, 2011 2:40pm

    Unifusion

    103 posts

    Yup, standard .htaccess redirect:

    Redirect /index.html <a href="http://www.domain.com">http://www.domain.com</a>
  • #6 / May 27, 2011 2:45pm

    Redirect /index.html <a href="http://www.domain.com">http://www.domain.com</a>

    If you nix that line from .htaccess, what happens?  I just tested one of my Structure powered sites and it showed the homepage of the site when I went to domain.com/index.html, even though I don’t have a template called “index.html.”  I’m not sure if that’s a feature of Structure or of EE.

    In other words, you may not need that index.html redirect, at least for the content to display correctly… I suppose you’d still want to get rid of it for SEO though.

  • #7 / May 27, 2011 3:00pm

    Unifusion

    103 posts

    If I remove the “index.html” or “home.html” lines from the .htaccess file the problem goes away.

    When I tested going to “http://www.mydomain.com/index.html”, I got a 404. Not sure why you got something different. Do you have your EE site set to redirect to the homepage instead of a 404 page? That may be why you got the result you did.

    I have to have “index.html” redirect because the client’s old homepage was at “index.html”. So it needs to be redirected in case one of their customers had it bookmarked, so she doesn’t get a 404 error on the new site. Same with “home.html” - it was a page on their old site and it needs to be redirected for SEO and for users who may have it bookmarked.

  • #8 / May 27, 2011 3:24pm

    It’s probably because I gave my homepage a Structure URL of index.html, so of course it worked. :: face palm ::

    Trying /index.html on a different Structure site, I got the same result you did - 404.  Sigh.

    Fortunately our other developer’s keeping an eye on this; here’s what he had to say:

    The person’s Apache is probably configured to try index.html as the default page name, so it is looping.  They might be able to change that by adding the line:

    DirectoryIndex index.php index.html

    - or -

    Redirect /index.html http://www.domain.com/index.php

    Note, with option 1, the DirectoryIndex line must go above the redirect rule(s).

  • #9 / May 27, 2011 3:35pm

    Unifusion

    103 posts

    Hey, it worked!

    I used

    DirectoryIndex index.php index.html

    before my Redirects and it worked great, plus home.html is redirecting correctly as well.

    Thanks, PressEnter!

  • #10 / May 27, 2011 3:39pm

    Wohoo!

    You’re welcome.

  • #11 / May 27, 2011 3:45pm

    Unifusion

    103 posts

    I should note that this doesn’t seem to work if you’ve removed index.php from your URLs - although I’m sure there’s a way to make everything play nice together.

  • #12 / May 27, 2011 3:56pm

    Try the other option and see if that’ll do the trick and play well with the other index.php rules:

    Redirect /index.html <a href="http://www.domain.com/index.php">http://www.domain.com/index.php</a> 
    Redirect /home.html <a href="http://www.domain.com/index.php">http://www.domain.com/index.php</a>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases