URL Not Matching

Hi,

I have an issue about following url

Working: /panel/upload/4705ab

UploadsController run great!

Not Working: /panel/upload/4705ed

But on this url, ErrorController run

And here my routes:

$router = new Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);

$router->add('/panel/upload/{key:[0-9a-z]+}', array(
    'namespace' => 'App\Controllers\Panel',
    'controller' => 'Uploads',
    'action' => 'upload'
))->setName('upload_action');

$router->notFound(array(
    "controller" => "Error",
    "action" => "index"
));

I'm getting this error more than a few routes too.

How i fix this?

Thanks

edited 23d ago

Are you sure you have issue with the route itself, perhaps your controller returns error? You'd have 404 if route was not found / unmatched and if you handled it properly.

By looking at your route pattern, it should match with no CAPS, e.g. only a-z.

Aye, tested myself too... working as intended.. perhaps you have condition in your controller as @jonathan suggested?



27.9k
edited 23d ago

Are you sure you have issue with the route itself, perhaps your controller returns error? You'd have 404 if route was not found / unmatched and if you handled it properly.

By looking at your route pattern, it should match with no CAPS, e.g. only a-z.

After your suggestions, i put the var_dump($key) top of function and output the $key.

So ok controller works but why not throw any errors? (Whole method in try catch block) Why running/redirect notFound proccess on error?

By the way this function was working great. But server changed and now broken some methods..



27.9k

Real example for this issue

Working: (with @gmail.net)

http://katalog.idp.org.tr/test/string/[email protected]

Not Working: (with @gmail.com)

http://katalog.idp.org.tr/test/string/[email protected]

Here my routes:

$router = new Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);

$router->add('/test/{code}/{email}', array(
    'controller' => 'Test',
    'action' => 'index'
));

$router->notFound(array(
    "controller" => "Error",
    "action" => "index"
));

And TestController:

class TestController extends ControllerBase
{
    public function indexAction()
    {
        $code = $this->dispatcher->getParam('code');
        $email = $this->dispatcher->getParam('email');

        var_dump($code);
        var_dump($email);
        exit;
    }
}

Provide info about your server env (OS, web server, php SAPI, etc).



27.9k

The issue reason found. Firewall and mod security deny some actions. We have to disable it.