Thanks for your help!
I’m sorry, my first message was incorrect as I discovered that the trailing slash didn’t really have an effect on the problem one way or the other.
It happens for me on Firefox, but not IE or Chrome.
I enter https://www.website.com/blog, and this takes me to the login prompt with the address
https://www.website.com/blog/wp-login.php?redirect_to=http%3A%2F%2Fwww.website.com%2Fblog%2F
I try to log in there, and the page refreshes and the address is the same. I submit the form again and get in.
If I use “return site_url();”, I never get past the login prompt.
This seems to happen only if I have the blog home page as the redirect target (whether by using my_forcelogin_redirect or, with my_forcelogin_redirect removed from functions.php, just the default behavior after browsing to that url). This also happens if I set the redirect explicitly to “/blog/index.php”. If I change the redirect target to something like …?page_id=xxx, it works fine.
When I change the redirect target from something else back to the homepage, (in Firefox again) everything works properly for three or four visits, and then the login form starts repeating again.
After the first time through the login form, I’m actually logged into the blog — I can browse directly to a subpage — even though it appears that I still need to log in.
It seems like Firefox is caching the original redirect (from homepage to login form). Or there is a timing issue — I’ve logged in and it’s redirecting me the homepage, but somehow WordPress doesn’t know that I’ve logged in yet, so it forces me to the the login form again.