【发布时间】:2018-07-10 17:13:36
【问题描述】:
好的,所以我刚刚安装了最新版本的 Symfony 4。安装后运行浏览器并显示一个漂亮的欢迎问候语。一切顺利!
然后我使用make:controller 创建了一个新控制器。我将此控制器命名为客户端并使用注释,与其他默认控制器相同。我配置路由如下:
/**
* @Route("/client", name="client")
*/
public function index()
{
// replace this line with your own code!
return $this->render('@Maker/demoPage.html.twig', [ 'path' => str_replace($this->getParameter('kernel.project_dir').'/', '', __FILE__) ]);
}
我刷新了浏览器,一切正常,没有错误。
然后我在浏览器中手动输入路径以检查它是否真的有效:
localhost:8000/client
问题。 url 返回标准 apache 404
Not Found
The requested URL /client was not found on this server.
Apache/2.4.18 (Ubuntu) Server at new.staff-fdr.dev Port 80
调试路线看到了这一点:
-------------------------- -------- -------- ------ ------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------
client ANY ANY ANY /client
index ANY ANY ANY /
_twig_error_test ANY ANY ANY /_error/{code}.
【问题讨论】:
-
缺少 htaccess。