【发布时间】:2018-01-31 16:14:08
【问题描述】:
我想打开另一个 url,让我们说:'localhost/test.html' 来自 cakePHP 中的页面。
我已经有一个视图(page.ctp)和控制器(PagesController.php)。在此页面上有一个名为 Wireshark 的按钮,每当我单击此按钮时,我都想转到另一个 URL,但不想重定向到 cakePHP 服务器中的另一个页面。
在 page.ctp 我使用这个:
<?php echo $this->Html->link(__('Wireshark'), array('controller' => 'tests','action' => 'wireshark'))?>
在 TestsController 中:
<?php
App::uses('AppController', 'Controller');
class TestsController extends AppController {
public function wireshark() {
}
}
在wireshark.ctp中:
<?php
echo "hello"
?>
直到现在,当我单击按钮时,它会将我重定向到“http://localhost:9877/tests/wireshark”并显示“hello”。我认为它工作正常,但我需要转到另一个网页(localhost/test.html)。
我也在同一个文件中尝试过:
<?php echo $this->Html->link(__('Wireshark'), 'localhost/test.html')?>
当我使用上面的代码时,我得到了这个:
错误:未找到请求的地址“/pages/localhost/test.html” 在这台服务器上。
我是全新的,自学 cakePHP。我用谷歌搜索了它,但没有一篇文章让我详细解释了如何做到这一点(可能是因为我对此很陌生)。
谁能帮我解决这个问题。很抱歉,如果不清楚,请向我澄清。
谢谢
【问题讨论】:
标签: cakephp