Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Redirect loop after update to 3.5.18 #8560

Closed
seaneble opened this issue Nov 4, 2016 · 27 comments
Closed

Redirect loop after update to 3.5.18 #8560

seaneble opened this issue Nov 4, 2016 · 27 comments
Assignees
Labels
Milestone

Comments

@seaneble
Copy link

seaneble commented Nov 4, 2016

We upgraded an installation from 3.5.17 to 3.5.18. The frontend is not reachable afterwards, accessing the home page returns code 302 redirecting to the same page over and over again.

Some analysis was possible before downgrading again (not too much because of the downtime).
The redirect is not related to any .htaccess magic (renamed for testing). The redirect comes from Contao (Cookie headers are also present in the HTTP response).

It does not seem to be related to #8547, because we don't have any PageRedirect pages in our tree.

It also does not seem to be related to #8552, because the error pages do not redirect in our setup, they are plain error pages with actual error messages.

Next step for us would be to try this in a testing environment. For the time being, I cannot recommend updating.

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

It has to be something in f42f2a4, but I was not involved in #8498 and don't know about the logic introduced there.

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2016

Can you make a copy of the installation available for debugging?

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2016

Btw. are you sure all the redirects from the redirect loop are coming from Contao? Because you mentioned that the status code is 302, however the status code of Contao's redirect implemented in f42f2a4 is 301.

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

No, see line 362.

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2016

My bad, was looking at the wrong lines.

You can probably solve your infinite redirect loop by giving your start page the alias index - however this is of course not a solution for the underlying bug.

@leofeyer
Copy link
Member

leofeyer commented Nov 4, 2016

How do I reproduce the issue with a fresh installation and the Contao Official Demo?

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

I'll provide a link to an SQL dump later in the day.

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2016

A complete copy would be needed, not just an SQL dump.

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

Need more time, music_academy.sql is not a part of the LTS download archive anymore (which I expected).

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

The problem only occurs because the page alias of our home page is /.
Currently I'm not sure why the alias is like that. The other question is whether it is something Contao should support.

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

One approach of course would be to change the alias.
But on the other hand one could argue that the change introduced in Contao 3.5.18 is a BC break and using / as an alias should still be possible (regardless of the sense of it).

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2016

Having an alias like / does not make much sense indeed. If you want to enforce a trailing slash for the empty request, you should define a redirect in your web server's configuration or the .htaccess for that.

Regarding fixing it: I am not sure if it makes a lot of sense to accommodate such a special case.

@seaneble
Copy link
Author

seaneble commented Nov 4, 2016

I agree with the first part. But BC breaks are not nice and might happen to other people as well. It as allowed behaviour, it should stay allowed behaviour.

@TorCoGit
Copy link

TorCoGit commented Nov 8, 2016

I had the same problem today. Deleting the following line from my personally adapted .htaccess solved the problem:
RewriteRule ^home\.html$ / [R=301,L]

@leofeyer
Copy link
Member

@seaneble Can you please post your .htaccess adjustments?

@seaneble
Copy link
Author

273,274c273
<   RewriteCond %{REQUEST_FILENAME} !-d
<   RewriteRule .* index.php [L]
---
>   RewriteRule .*\.html$ index.php [L]

@leofeyer
Copy link
Member

So your alias is /.html???

@seaneble
Copy link
Author

Was. The diff is the other way around. Alias is empty.

@fritzmg
Copy link
Contributor

fritzmg commented Nov 15, 2016

@leofeyer seaneble's issue is fixed now anyway. The problem was, that he used / as the alias for the start page. The question is now, whether Contao should support such an alias or not. In Contao 3.5.17 it was possible, but in Contao 3.5.18 it is not.

@leofeyer
Copy link
Member

Using / as alias does not make sense IMHO. It might have been possible before Contao 3.5.18, but it was never explicitly supported.

@seaneble
Copy link
Author

I agree with the fact that '/' never was a good idea. Nevertheless, people (at least we) did use it in some projects. The complete site was broken after a maintenance update, which should not happen.

Perhaps one could include a migration step to change the alias from / to empty in Contao 3.5.19?

@leofeyer
Copy link
Member

I'm still trying to reproduce your setup, which I cannot as long as you are not providing the necessary details (such as the current .htaccess configuration instead of the former one).

@fritzmg
Copy link
Contributor

fritzmg commented Nov 15, 2016

The reproduction steps are:

  1. Use an empty HTML suffix in the system configuration.
  2. Set the alias of the start page to /.
  3. Use the following directives in your .htaccess (regarding the URL suffix,)
RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|zip|gz)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Then open http://example.org or http://example.org/. There should be infinite redirects.

@leofeyer
Copy link
Member

Thank you @fritzmg, I was able to reproduce the issue now.

This is actually a quirk of the Environment class, which returns all paths relative to the <base href=""> URL. Therefore http://example.org/ becomes '' in the Environment class, whereas it becomes '/' in the $_SERVER['REQUEST_URI'] variable. At least this is the behavior with Nginx and PHP-FPM.

I could hardcode a fix for this specific case, but I don't know if I should. @contao/developers /cc

@seaneble
Copy link
Author

I was going to provide a zip of the Music Academy with broken settings today, but thanks to @fritzmg that is superfluous now. Great!

@Whissi
Copy link

Whissi commented Dec 30, 2016

Today I run into the same problem after upgrading Contao. Please implement the mentioned fix at least for 3.5.x because it is a very bad experience when updating a LTS version and you notice that your start page doesn't work anymore.

@leofeyer
Copy link
Member

Fixed in b565df6.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jan 20, 2017
 * Correctly handle nested public folders when symlinking a folder.
 * Correctly handle SVGZ files in the file manager (see contao/core#8624).
 * Prevent an endless redirect loop if the page alias is "/" (see contao/core#8560).
 * Correctly parse German dates with two digit years in MooTools (see contao/core#8593).
 * Correctly add new resources to the user/group permissions (see contao/core#8583).
 * Trigger the auto-submit function in the date picker (see contao/core#8603).
 * Call the load callback when loading page/file picker nodes (see contao/core#7702).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants