Skips homepage, goes straight to login

Skips homepage, goes straight to login

by Justin Case -
Number of replies: 18

Greetings all.  My issue is that navigating to my website brings my users straight to the login page.  Yes, I know this issue has been discussed before, but, still, after pouring through the posts, I can't find a solution.  I've done what the other posts have suggested:  made sure to uncheck "forced login", checked the config.php file, and I've looked for any weird URL redirects on the server.  I also checked the database settings (config) and the "forced login" is indeed set to 0.  This happens even when "/index.php" is appended to the url.  Also, it's not my computer (browser, cookies, cache, etc.); it happens on any computer.  It's not the end of the world, but it's just so frustrating because I can't think of anything I did to cause this.  Any suggestions will be greatly appreciated.

I'm using Moodle 3.6.2 (Build: 20190114)

Thanks very much.

Average of ratings: -
In reply to Justin Case

Re: Skips homepage, goes straight to login

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

It looks like you've checked everywhere: it's got to be one of those places. It's possible that forcelogin has been enabled in the past and the server-side Moodle cache has this value so it's worth trying a cache purge to see if that helps.

Also, you could try opening a browser window in privacy mode with the network monitor enabled and accessing the home page to see if the first request (the one that gets redirected) gets a MoodleSession cookie set in the response. If it does then it suggests Moodle is doing the redirect. If it doesn't it suggests the web server (or something in front of it) is doing the redirect.

Also, the network monitor would show exactly what type of redirect is occurring, e.g. 302 or 303, which may help identify the culprit.

These last two suggestions are a bit detailed, if you share the site's URL we can check these but it's fine if you'd prefer not to.

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Skips homepage, goes straight to login

by Justin Case -

Thanks so much for your reply! I really appreciate it. Unfortunately, the purge didn't work. I'll look at your other suggestions and post any successes herein. The site is lourosenberg.com which redirects to lourosenberg.com/start. I've been using the redirect for ages and never had a problem; and of course I played with it extensively in light of this issue. Again, thank you.

In reply to Justin Case

Re: Skips homepage, goes straight to login

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

If I’m understanding what you’ve written, the expected behaviour is that going to lourosenberg.com automatically redirects to lourosenberg.com/start without requesting login. And this was working previously.

When did it start requesting login? Do you have an .htaccess file your server? Or a redirect set up via a control panel?

From memory, you were also using Dreamweaver at some point to integrate your website - are there any meta-refresh statements in the index page on lourosenberg.com?

Average of ratings: Useful (1)
In reply to Jon Bolton

Re: Skips homepage, goes straight to login

by Justin Case -

Hi John.  Thanks for your input; I really appreciate it. Please see my comments below, in-line.

If I’m understanding what you’ve written, the expected behaviour is that going to lourosenberg.com automatically redirects to lourosenberg.com/start without requesting login. And this was working previously.

  • Yes; that's right.

When did it start requesting login? Do you have an .htaccess file your server? Or a redirect set up via a control panel?

  • Around the middle of the month.
  • I do have .htaccess files, but they seem fine to me.  They deal with the ssl; the redirect to /start is set up via Cpanel, and I can't seem to find any issue there.

From memory, you were also using Dreamweaver at some point to integrate your website - are there any meta-refresh statements in the index page on lourosenberg.com?

  • What a memory!  Yes, that was awhile back, and it never got off the ground primarily because my technical skills amount to an uneven patchwork wrought out of survival.  I'm using Moodle, straight out of the box.


In reply to Justin Case

Re: Skips homepage, goes straight to login

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The browser request to start/ sets the MoodleSession cookie which suggests Moodle is doing the redirecting.

If forcelogin is off in the database maybe there's some caching involved. I'm not an Nginx expert but it's probably worth restarting this.

Also you could try adding $CFG->forcelogin = 0; to config.php.

Failing that, as Jon suggests, if this behaviour wasn't happening previously try to identify when this started and what changed. Maybe the web server logs will show when requests to start/ stopped returning 200 OK (i.e. no redirect) and started returning 303 See Other. Moodle config changes made through the web site should appear in Site administrationReportsConfig changes which might help identify changes.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Skips homepage, goes straight to login

by Justin Case -

Hi Leon.  Thanks again for your help.  I tried the additional line to the config.php file, but it didn't work.  So, more sleuthing....


All best,
Lou

In reply to Justin Case

Re: Skips homepage, goes straight to login

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Do you have any third party plugins which could be causing this? To see these go to Site administrationPluginsPlugins overview and look at Additional plugins.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Skips homepage, goes straight to login

by Justin Case -

Hello Leon. I don't think I do. The semester is almost over, and, for fall 2019, I will just install another instance of Moodle and start afresh. I'm wondering if there is any way to "trace" - instant by instant; line by line - the loading of a URL so that one might watch it mature from conception (the firing of its first line of code induced by the initial browser request) to fruition (the mature web page)...??  Anyway, thanks so much for all of your help.

In reply to Leon Stringer

Re: Skips homepage, goes straight to login

by Clarence Prudhoe -

Hi,  I suffered the same problem of opening the site page and it redirecting to the login page.

I tried all of the "fixes" indicated in this forum but everything seemed to be correct.

I traced my problem to /moodle/lib/outputrenderers.php  line 1380   $footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);

I don't understand what this does, but in desperation I just commented it out and now my Moodle site works as expected.

    //  $footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);

It no longer redirects to the login page and yet, since I have the login block included on the Site page, I can login and it all works. 

Hope this helps.

Clarence

In reply to Clarence Prudhoe

Re: Skips homepage, goes straight to login

by Clarence Prudhoe -

OOPS!  CORRECTION:

commenting out    //  $footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);

eventually creates a FATAL ERROR!

Disregard my previous post.

I have spent a lot of time trying to fix this problem but I am still at a loss as to what is causing the redirection to the login page.

Clarence

Average of ratings: Useful (1)
In reply to Clarence Prudhoe

Re: Skips homepage, goes straight to login

by Justin Case -

Clarence, I think you're on to something because, as I remember it now, I was working on the footer when this started happening. I hadn't thought anything of it until your mention of it.

In reply to Justin Case

Re: Skips homepage, goes straight to login

by Justin Case -

Also, I wonder why it "eventually" causes the fatal error. My nontechnical brain thinks that it either would or it wouldn't. Hmmm.... Indeed, the footer...

In reply to Leon Stringer

Re: Re: Skips homepage, goes straight to login

by Clarence Prudhoe -
Hi Leon, I am at a loss as to what is causing this behavior. I have eliminated all of the suggested issues in this string of posts but the behavior persists. You can see this happen if you open https://www.musapp.com/music/index.php Thanks for any suggestions. Clarence
In reply to Clarence Prudhoe

Re: Skips homepage, goes straight to login

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

@Clarence - that url loads your website and then after a very slight pause, redirects to the login page. That suggests there is some redirect going on at page load. Looking at your page source, there is a GDPR cookie consent script running. Try disabling that script temporarily to see if it stops redirecting to the login page.

Also, in that script, it looks like the source is wrong - it should probably have an http/https before the www, otherwise the server will try to locate it on YOUR server. That MAY be the problem - it looks like your web server is trying to find something that it thinks is local and is therefore asking you to log in.

The script form your website is below. Note the line that starts src="//www">

<script>
var eu_check = "no";
var redirect_eu = "";
var redirect_url = "";
</script>

<script type="text/javascript"
src="//www.softwareapp.io/gdprguard/show.js?id=45"
data-name="gdpr_include">
</script>
<div class="gdpr_holder">
</div>
In reply to Jon Bolton

Re: Skips homepage, goes straight to login

by Clarence Prudhoe -

Thanks for looking at this Jon, I'll check out that code.

I traced the referrer to the front page footer.  When it outputs the footer it calls function footer().  The function,  footer() compiles the output in a variable called $footer.  One line of code adds a call to unique_end_html_token and the function get_end_code().  I have studied this code and see that the unique_end_html_token is a SESSION number and the get_end_code() does a number of things including in calling the variable  $URL.  I don't see what is triggering the call to /longin/index.php.

The code in question is in /lib/outputrenderers.php, line 1379:

$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);

I commented this line out and when I open www.musapp.club, it stops on the front page and everything seems to work OK.  I don't know what ells will be broken without this line of code.  But for now, it works.

If anyone can shed some light on why the unique_end_token or the funciton get_end_code() is redirecting the site to the login page, I would appreciate your input.

Thanks,

Clarence

In reply to Jon Bolton

Re: Re: Skips homepage, goes straight to login

by Clarence Prudhoe -
Jon, I fixed the src= url and now it no longer jumps to the login page. src="https://www.softwareapp.io/gdprguard/show.js?id=45" Thanks for your help, I have spent way too many hours trying to fix this. Thanks again, Clarence
In reply to Clarence Prudhoe

Re: Re: Skips homepage, goes straight to login

by Clarence Prudhoe -

Hi Jon,

OOPS!  I opened MusAPP.club this morning and it skipped the front page and went directly to the login page!

Back to square ONE!  

Then I started removing the Front Page blocks and discovered that the problem was with the My Recently Accessed Activities block.

Since you must be logged in to access a course listed in the My Recently Accessed Activities block, it was forcing the login page to open.

I changed the setup for the My Recently Accessed Activities block so it does not show on the Front Page.

Problem solved!

Thanks,

Clarence

In reply to Justin Case

Re: Skips homepage, goes straight to login

by Justin Case -
I just uninstalled the Event Reminders plugin and the problem is fixed! 
Average of ratings: Useful (2)