SSO Rewrite Rules tend to be forgotten

Hi there!

I've been encountering this same issue for over a year now:
> Sometimes, either the mapped or main domain returns a 404 error when trying to access Single Sign On rules.

Is this a known issue?
And what are the exact rules? I might be able to apply them within .htaccess.

Thanks!

  • Adam Czajczyk

    Hello Sybre,

    I hope you're well today and thank you for your question!

    I can see that you are using our Domain Mapping plugin but I admit I'm a bit confused. By SSO (Single Sign On) we usually refer in this case to the "Cross-domain autologin" option which is a simple "Yes/No" switch.

    As you are referring to the "rules" in the context of our Domain Mapping plugin I must say that I'm not sure what do you mean. I suppose I'm missing something obvious here so could you please elaborate a bit on this so I could better understand your question?

    Please advise!

    Best regards,
    Adam

  • Dimitris

    Hey there Sybre Waaijer,

    hope you're doing good today and don't mind chiming in! :slight_smile:

    I tend to believe that this is indeed a .htaccess conflict as saving permalinks re-constructs any rewrite rules by writing to this critical file. More info can be found here https://codex.wordpress.org/Using_Permalinks.

    Having said that, it would be perfect if you can reproduce these 404 issues and take a copy of the .htaccess file at this moment. Then, resave permalinks in order to resolve it and take a second copy of the .htaccess. You can then rename these files like htaccess-old.txt and htaccess-new.txt and attach them here in a reply (files should not be hidden and should have a .txt extension in order to get attached in our forums). This comparison may give us some good info on what may interfere there.

    As far as I can understand this replication may be tricky though, as you mentioned that this is happening sometimes. Are there any updates or new plugins/themes installed in your WP installation that you recall before you start dealing with issues? Please advise! :slight_smile:

    Kind regards,
    Dimitris

  • Sybre Waaijer

    Thank you so much for your time Dimitris !

    I can't recall what plugin has caused this, as it's quite a long time ago.
    It's either core, or one of my own (ugh..).

    I also made a post earlier about the rule initialization, found here.
    It's mainly about the same issue, but this one is more focused on the .htaccess file rather than the plugin itself. The adjustment suggested to be working for the time being, but I soon ran into the same issue again.

    Unfortunately, I can't afford disabling the current rules (they're mostly disabling file browsing and forcing HTTPS on some sites), as some production sites rely on those rules within the network.

    I do believe hard-coding the required rewrite rules is a great possibility for a solution.
    If I encounter this issue again (I hope soon :smiley:) then I'll see if forcing some rules would fix the problem.
    I'll snoop into the code when the time comes.

    I'll report back with the rules and results.

    Until then, have a wonderful day! Cheers!

  • Sybre Waaijer

    Well, editing htaccess was impossible, as the variables that are checked against are pulled directly from WP_Rewrite's caches.

    Nevertheless, I found the solution, and I already have it running on my website.
    I "simply" edited the ways the Rewrite endpoint is called on. I also added a key revision so the whole network got flushed correctly.

    Feel free to push the following file to the plugin author, let me know what you think!
    Patch file

    Summary:
    - The query vars are now correctly filtered into the right filter. Action init is not the right filter.
    - The flush now happens on shutdown, this will prevent plugin conflicts. As some plugins might add rewrite rules later than "init action 10".
    - I cleaned up some code as I went through.
    - Flush revision key has been added.

    Cheers!

  • Milan

    Hello Sybre Waaijer ,

    Hope you are doing well today !!

    Thanks a lot for your patch. I'll make sure that it gets our developer's attention. I am glad that you made your fix on your own. Really great work.

    Furthermore, I can see that you are using an older version of Domain Mapping plugin. So would you please take some time and upgrade it to its latest release ? If you are not sure how it will go for your live site, then you can always create staging site to test update there. :slight_smile:

    Let me know if you have anything else to ask. :slight_smile:
    Best Regards,
    Milan

    • Sybre Waaijer

      Hello Milan,

      I just compared the two versions (4.4.2.3, which I have installed, and the current at version 4.4.2.4).
      No executable code differences are within the Cdsso.php file (for which the patch file is based upon).

      Throughout 4.4.2.4 I only found textual improvements, and of course the "www." fix.
      In no way are any changed in 4.4.2.4 related to my changes so the patch file is still valid (but the lines might be a little off, at most by 3) :slight_smile:.

      If, for any technical reasons, you'd still wish to obtain an updated version compatible with the code lines in 4.4.2.4. Feel free to ask and I'll provide!

      Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.