标签: cakephp-routing

将查询字符串传递给cakephp中的蛋糕样式URL并提供HTML的ext

我想要实现的目标:

用户通过时:

/results?val=real&x=1&y=0
Run Code Online (Sandbox Code Playgroud)

它应该显示:

/results/real.html?x=1&y=0
Run Code Online (Sandbox Code Playgroud)

从Action我应该仍然能够访问$this->request->query['val']哪些应该等于real

到目前为止我做了什么?

我正在使用CakePHP 2.4

Router::parseExtensions('html');

Router::connect('/results/:val', 
            array('controller'=>'Post','action'=>'results',
'?' => array('val'=>'[A-Za-z0-9]-_ +','x'=>'[0-9]+','y'=>'[0-9]+')));
Run Code Online (Sandbox Code Playgroud)

php cakephp cakephp-routing cakephp-2.4

9
推荐指数
1
解决办法
7426
查看次数

CORS 预检通道未成功。仅在 Firefox 中。铬工作正常

所以我有一个不寻常的问题,我不确定如何进行调试。我有一个 angular 4 应用程序,它在服务器端使用 cakephp。

在我的应用程序中,我有许多不同的屏幕,我可以正常访问,除了一个并且它只是 Firefox 的一个问题。如果我使用chrome,我可以打开它。我在 Firefox 中收到以下警告

跨域请求被阻止:同源策略不允许读取位于http://localhost:8080/api/cross-series/network-series的远程资源 。(原因:CORS 预检通道没有成功)。

这是我用来导航到屏幕的链接

<div class = "col-xs-4 col-sm-4 col-md-4 col-lg-4"  [routerLink]="['/dashboards/cross-series/network',{networkId:3}]">

            <img src = "assets/img/networks/com-circle.png" class = "cross-series-navigation-icon clickable"
                 alt = "Com"/>

        </div>
Run Code Online (Sandbox Code Playgroud)

然后在 php 中,我有以下 Cors 代码

        $this->response->header('Access-Control-Allow-Origin', 'http://localhost:4200');
//  $this->response->header('Access-Control-Allow-Origin', 'http://localhost:8066');
        $this->response->header('Access-Control-Allow-Credentials', 'true');
        $this->response->header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, DELETE');
        $this->response->header('Access-Control-Allow-Headers', 'Origin, Authorization, X-Requested-With, Content-Type, Accept, Cache-Control');

        header_remove('X-Powered-By'); //remove default PHP header

        array_push($this->allowedActions, 'options');


        CakeLog::debug("This is the action: " . print_r($this->action, true), 'debug');
Run Code Online (Sandbox Code Playgroud)

在日志中,我可以看到 Firefox 和 Chrome …

php firefox cakephp cakephp-routing angular

3
推荐指数
1
解决办法
2万
查看次数

CakePHP 3 路由:如何路由控制器基础

我正在使用 cakephp 3。我想frontends在 url 中隐藏控制器。

我的路线配置:

Router::connect('/:action', array('controller' => 'frontends'));
Run Code Online (Sandbox Code Playgroud)

bloggers当 url 开始时,我想将所有功能都指向控制器www.example.com/bloggers

Router::connect('/bloggers/:action', array('controller' => 'bloggers'));
Run Code Online (Sandbox Code Playgroud)

www.example.com/bloggers也指前端控制器的索引功能。应该是指博主Controller的索引功能。有什么帮助吗?

cakephp cakephp-routing cakephp-3.x

2
推荐指数
1
解决办法
499
查看次数