Search code examples
phpzend-frameworkpimcore

URL allows special character in the end. Why?


My domain name allows special character (www.testing.com/home/login-) at the end. How do I ensure this is not allowed and show page does not exists cause the right URL is www.testing.com/home/login

$routeCustom = new \Zend_Controller_Router_Route(
    '/:controller/:action',
    array(
        'module' => 'website',
        "controller" => "default",
        "action" => "default"
    ),
    array(
        'controller'=>'^[a-zA-Z-_0-9]+', //accept:  a to z , A to Z , - , _ , 0-9 
        'action'=>'^[a-zA-Z-_0-9]+'
    )
);

Solution

  • This is how:

    $routeCustom = new \Zend_Controller_Router_Route(
        '/:controller/:action',
        array(
            'module' => 'website',
            "controller" => "default",
            "action" => "default"
        ),
        array(
            'controller'=>'^[a-zA-Z-_0-9](.*[a-zA-Z0-9])$', //accept:  a to z , A to Z , - , _ , 0-9 
            'action'=>'^[a-zA-Z-_0-9](.*[a-zA-Z0-9])$'
        )
    );