CMS page URL pattern prioritisation or overriding for certain URLs

Hi, I have 2 CMS pages using the following url syntax:

  1. /ideas/:slug?
  2. /:fullslug?*

Some pages are gradually being moved from using CMS page 1 to CMS page 2 so I need to keep both for now, especially as both of them use different layouts. Unfortunately I can’t figure out how to force CMS page 2 to be used when the url is something like ideas/some-post. It potentially matches both but the first CMS page takes priority and I get a 404 because it’s not the correct page for that url.

Therefore I could do with a way of redirecting to, or forcing usage of, the second CMS page for certain urls instead of the first. Is there anything I can use to do this?

I have tried determining the correct page to use in the PHP code of CMS page 1, which is fine, but if I try to return something like Cms::redirect() to redirect to the other CMS page I just get a redirect loop because it still ultimately just redirects back to the same CMS page again due to the higher priority (I’m guessing).

I hope that makes sense. Apologies if I’m missing something obvious.

I think I’ve been able to solve this by hooking into the beforeDisplay event as documented here - beforeDisplay - October CMS

I can do whatever checks I need to determine if a different CMS page should be used and then return the desired CMS page as necessary.

The fullslug parameter required by the eventual CMS page wasn’t immediately available so I had to add it by setting it to the router parameters via the controller provided by the event. No big deal.

You should think about introducing an URI or slug prefix to make the sites distinguishable. It’s just not a good idea to occupy the whole URI namespace and have to workaround that fact with coding. That will haunt you at some point in the future.