D
D
Dom Alfro2020-04-30 15:28:34
PHP
Dom Alfro, 2020-04-30 15:28:34

Why can't I find what I want to find by url?

Good day !
I wanted to ask - I have routes configured in routes

'main/index/{id:\d+}' => [
      'controller' => 'main',
      'action' => 'index',
    ],

but does not find anything if you write main/index/123 - for example
, here is the configuration in the routing itself
public function add($route, $params) {
        $route = preg_replace('/{([a-z]+):([^\}]+)}/', '(?P<\1><\2>)', $route);
        $route = '#^'.$route.'$#';
        $this->routes[$route] = $params;
    }

it is not clear why the parameters should not be located,
it should still display information exactly
why it displays 404 for me
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dom Alfro, 2020-04-30
@mustang_shelby

solution open !!!!
I didn't screen correctly!
it was all in regular expressions ... oh, already those quotes and brackets ... I went crazy for 3 weeks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question