PHP SLIM不接受uri参数中的点(.)

PHP SLIM不接受uri参数中的点(.),php,slim,Php,Slim,我正在尝试使用slim构建一个亵渎过滤API。下面是该api的链接 Link : http://www.employeeexperts.com/Profanity/index.php/rest/check/hello 在链接的最后,我加上“hello”这个词来检查亵渎。到目前为止,它工作正常。但是,当我在单词末尾添加任何点(.)时(例如:hello…),Slim将控件重定向到索引页 我的GET路由器代码如下 $app->get('/service/:method/:str', funct

我正在尝试使用slim构建一个亵渎过滤API。下面是该api的链接

Link : http://www.employeeexperts.com/Profanity/index.php/rest/check/hello
在链接的最后,我加上“hello”这个词来检查亵渎。到目前为止,它工作正常。但是,当我在单词末尾添加任何点(.)时(例如:hello…),Slim将控件重定向到索引页

我的GET路由器代码如下

$app->get('/service/:method/:str', function ($method, $str) use ($app) {    
     // Internal codes goes here
});
有谁能帮我想办法阻止这一切吗


关于

看来默认的GET路由器不允许URL以点结尾。如果点后有任何字符,页面将正常运行。作为替代方案,您可以尝试自定义管线条件,如下所示:

您的案例示例:

<?php
$app = new \Slim\Slim();
$app->get('/service/:method/:str', function ($year) {
    echo "You are viewing archives from $year";
})->conditions(array('str' => '([a-z]+)', 'str' => '(.*)'));

我也有这个问题,这是我的解决方案:

$app->get('/service/+args', function ($args) use ($app) {    
    $arguments = str_replace("/service/", $app->request->getPathInfo());
    $args = explode('/', $arguments);
    var_dump($args);
});
当我访问URL
/service/foo/bar
时,
$args
如下所示:

array(
    'foo',
    'bar',
)
array(
    'foo',
    'bar',
    'baz',
    'qux',
)
另外,当我访问URL
/service/foo/bar/baz/qux
时,
$args
如下所示:

array(
    'foo',
    'bar',
)
array(
    'foo',
    'bar',
    'baz',
    'qux',
)

这种情况不起作用。关于用POST方法发送数据,我也认为这将是更好的解决方案。