New route for existing route?

To solve something else, i try to play with routes, i can do something like

when “haha”, then show html “haha huhu”

but when i try this with: “/notes/page:2” nothing happens.
So these route is still there, i cant replace it?

Thank you very much for your kindness to send this link.
I really have tried my best and here is the result:

    [
      'pattern' => '(:any)',
      'action'  => function () {
        return page('about');
      }
    ],

when i type in: localhost/be_polite i will be redirected to the page localhost/about.

But what when i call the existing page

localhost/notes i still get localhost/notes

Maybe i have not seen the warning on this page above with something like:
You cant reroute existing routes!

But maybe this warning is somewhere and i cant see it, ok.

So lets try some code from this page:

     'routes' => [
        [
            'pattern' => '(:any)',
            'action'  => function($uid) {
                $page = page($uid);
                if(!$page) $page = page('notes/' . $uid);
                if(!$page) $page = site()->errorPage();
                return site()->visit($page);
            }
        ],
        [
            'pattern' => 'notes/(:any)',
            'action'  => function($uid) {
                go($uid);
            }
        ]
    ]

from

but funny, funny, nothing happens. When i call notes/first_article it still stays notes/first_article

config:cache is on false.

What can i do now to come from /notes/some-article to /some_article ?

1 Like

To reproduce the problem, i tried:
localhost/notxxx/first_article and get localhost/first_article

I dont know to say this polite: maybe it is possible to add a small sentence for noobs on the linked page to docs with something like:

Hey, you cant reroute existing pages!

or

Hey, you cant reroute existing pages! But here is the magic trick to do it! => Link


While it is not possible to reroute something like notes/page:2, then it is not possible to do a static page for this not existing page, i guess?

While i am the only one having such a problem, this could mean:

  • nobody else tries to use routes
  • there is a difference before pre and after route; maybe my system uses after route? How can i change it to pre?
  • problems with htaccess and rewrite? Dont think so, while notex/something is rerouted, but notes/something not. But i will check and clean the htaccess.
  • problems with my wsl2 on windows and ubuntu? Dont think so, but add a new web to the webserver and try it there in real life.
  • no license, no route? But i have added my license now also to localhost (but maybe with the wrong domain? - But the info says “registered license”)
  • anything else?

Again to repeat:
:any reroutes every url i use, when the file is not existing.
:any doesnt reroutes url, when the file is not existing.

noex/a_page => a_page
notes/a_page => notes/a_page