Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless redirect loop on some subsites #41

Open
robrecord opened this issue Feb 25, 2015 · 20 comments
Open

Endless redirect loop on some subsites #41

robrecord opened this issue Feb 25, 2015 · 20 comments
Assignees

Comments

@robrecord
Copy link

On the latest release 306176a - compared to what I had before I pulled (0f07fc6), I get the following behaviour.

Two of my subsites go into an endless redirect loop between their proper www.domain.com address, and something like rootsite.com/wp-admin/ajax.php?page=mercator-sso (could be that or page=mercator-sso-something) with a few other (long) arguments in the query string. The other sites are fine.

My setup: I have several sub-sites on a multisite network. Each sub-site is accessed by its own domain; I have the sub-site's domain www.domain.com as the sub-site URL set in network site settings (info tab), and an alias for non-www domain (active) and domain.rootsite.com (active). The two sub-sites that have a problem have domains that are hosted by hosting provider 'B' (whereas the rest of my sites are hosted by provider 'A'). I have confirmed with domain provider B that there are no problems with the DNS or anything their side.

I have tried removing all cookies. I have tried using private browsing mode in safari.

As these are production sites, I had to use git to hard reset.
+1 vote for tagging stable releases please :) My clients are counting on it.

@adambiggs
Copy link

Same issue here. @humanmade please advise

@adambiggs
Copy link

In my case, the redirect loop was happening because I changed the main "Domain" field under the "info" tab.

When I put this back to the default subdomain value, and instead added the custom domain under the "Aliases" tab, everything started working.

@rmccue
Copy link
Member

rmccue commented Feb 25, 2015

Apologies for the breakage here. We've been working on improving the plugin based on our usage patterns, but looks like there might have been some bits missed in the process.

@tcrsavage Looks like there's a regression here, do you have time to look into it?

@scottsweb
Copy link

I can confirm I have this exact same issue. One site seemed OK. The other was looping.

@robrecord
Copy link
Author

@tcrsavage is there any chance you have the time to check it out? I believe I need to upgrade this plugin as some people say they get 404 pages when visiting URLs on my WP install, that are working on my end, but am reluctant to upgrade because two of my sites will break for the reasons above.

@tcrsavage
Copy link
Contributor

@robrecord sorry should have left a comment here. Pushed this issue over to @rmccue due to workload. We're all hands on deck at the moment with a few big product deployments, sorry for the delay!

@robrecord
Copy link
Author

No problem and thanks for the update! Appreciate the work you guys have done.

@rmccue
Copy link
Member

rmccue commented Mar 30, 2015

an alias for non-www domain (active)

Looking into this issue now, and I can't say I really understand what's happening. I'm thinking the non-www alias could be the issue though, as Mercator treats www and non-www the same when searching. Try removing the non-www and see if that helps?

If not, can you give a step-by-step process to replicating the issue? Alternatively, a quick description of what's happening plus the data from your wp_domain_mapping table might be useful.

@crazyjaco
Copy link

I have a similar issue.

I try to log in to my subsite's dashboard and it starts an endless chain of forwarding, navigating to this url with the key and nonce changing each attempt:
http://subsite-domain.com/subsite/wp-admin/admin-ajax.php?action=mercator-sso-login&key=xxxxxxxxxxxxxxxxxxxxxxx&nonce=xxxxxxxx

My root site/admin is the only site and dashboard I can successfully navigate to.

This is in a production environment.

@crazyjaco
Copy link

If I logout and go to my subsite's domain, the html loads, but none of the images, scripts or styles load.

I get 404 errors for the url:
http://rootdomain.com/subsite/wp-content/sites/#/2015/##/xx.png

The following urls work and load the image appropriately:
http://rootdomain.com/wp-content/sites/#/2015/##/xx.png
http://subsite.com/wp-content/sites/#/2015/##/xx.png

It doesn't like that subfolder name in the url.

@crazyjaco
Copy link

I resolved this by disabling SSO, resetting my network's .htaccess rules and clearing my cookies.

@scarstens
Copy link

I also have this problem. To recreate the problem:

  1. Create subdomain subsite (lets call it siteb.mainsite.dev)
  2. Create an alias called siteb.dev.
    (at this point you can visit and login to siteb.dev but there are some issues with leaving the setup like this)
  3. Change the site_url from siteb.mainsite.dev to siteb.dev on the site edit screen (updates site_url and home_url in the db).
  4. Login to mainsite.dev.
  5. Try switching to siteb.dev (infinite redirect loop).

@tholu
Copy link

tholu commented Dec 21, 2015

+1 for fixing this

@robrecord
Copy link
Author

Hi @scarstens

Create an alias called siteb.dev.
(at this point you can visit and login to siteb.dev but there are some issues with leaving the setup like this)

What issues have you found?

@scarstens
Copy link

issues, as I mentioned on the other github issue you commented on, relate to how WordPress links to wp-admin URL's.

@robrecord
Copy link
Author

Sorry @rmccue - I didn't have time to troubleshoot as you asked of me last year.

Though I can now confirm that leaving subdomain as site URL resolves the issue. (I perhaps hadn't cleaned caches/replaced wp-config salts last time I tried it.)

@mrjarbenne
Copy link

Though I can now confirm that leaving subdomain as site URL resolves the issue. (I perhaps hadn't cleaned caches/replaced wp-config salts last time I tried it.)

What if one didn't want to leave the Site Address as the unmapped domain? I can confirm this issue is happening in some instances unless I leave the subdomain as the Site Address. Perhaps I'm misunderstanding how this plugin could potentially work.

This is what I'm imagining:

I have a Multisite network, on which I want to offer support for custom domains. Since WP 3.9, I'm able to change the Site Address to whatever I want, and as long as I sort out the authentication cookie, I should be good to go. See #3 and @rmccue's comment:

As of WP 3.9+, you can set the URL to basically anything you want to change the "primary" site (you could then alias the old one back). Not sure if that fits your use case though?

Because he's saying you "could" set the alias to the old one, I read that to mean that I don't have to. Mercator then becomes a mechanism for me to enable cross domain cookie support through the SSO functionality, allowing my users to navigate across the network regardless of the domain.

If alternatively I want to have multiple domains pointing to the same subdomain, I can also accomplish this through aliases. So conceivably I could take an unmapped domain from my multisite (eg site1.domain.com) and delete the unmapped domain from the Site Address field in settings, replacing it with a new domain (eg. betterdomain.com) along with a second alias in the alias tab (eg. otherbetterdomain.ca), and allow people to find my site through two different domains (SEO issues aside).

Are others experiencing this redirect loop? Any thoughts on a fix? Am I misunderstanding the use-case for this plugin?

@jjeaton
Copy link

jjeaton commented Aug 10, 2016

@mrjarbenne we have seen the same issue and were only able to resolve it by making the primary domain in wp_blogs be a subdomain of the primary domain (sitea.site.example.com) while our mapped domain is (sitea.example.com). We don't have full organizational control of all of example.com only site.example.com which is why we have the multi-level subdomains.

sitea.site.example.com only exists in the wp_blogs table for us. We search replace for the mapped domain otherwise we end up with CORS issues. This setup has the following issues for us:

  • We cannot access the site under sitea.site.example.com (the wp_blogs domain) without CORS issues. I tried implementing an open PR: fixes #32 and fixes #51 #59 but it did not fix it for us. As I tried to implement that PR, I discovered that $mercator_current_mapping was not set when visiting the site's wp_blogs URL (sitea.site.example.com) because it also did not exist as a mapping. Even when adding it as a mapping, it doesn't work because the current mapping global doesn't get set if the site_url matches the current mapping.

We are using mercator for the SSO feature as well, and would love a resolution to this. Happy to submit a PR, but also want to make sure we are using it correctly.

@marcoherzog
Copy link

@jjeaton to cut a long story short... I think the problem is that COOKIE_DOMAIN does not get defined here since this change.

I just made sure, that COOKIE_DOMAIN gets defined again.
See: marcoherzog@5e91c40

I did not take a deeper look into the code. But mapping now works as expected. At least for my setup.

@mikelking
Copy link

@jjeaton,

If I read you resolution correctly you lifted the www.UNIQUE-DOMAIN.com from the mapping of site 2 and set it to be a subdomain of the root (site 1 domain). I am betting you're on WPE btw. So you ended up with unique.mgmt-site.wpe.com because wpe hosts ALL multisites from their own domain. Then you used the mapping to map www.UNIQUE-DOMAIN.com as an alias for the unique.mgmt-site.wpe.com (sub-subdomain).

I am still not certain that this would resolve my issues but I could set unique.mgmt-site.wpe.com as the origin for my CDN where www.UNIQUE-DOMAIN.com actually lives. 🤔

If that works it's not the end of the world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests