更容易访问 Symfony 4 中的另一个网络应用程序

Easier access to another web app inside Symfony 4

我有一个 Symfony 4 网络应用程序。假设它是 http://example.com.

我已经在 /public/hesk/ 安装了 HESK。 现在可以通过 http://example.com/hesk/index.php 访问 HESK,但是当用户跳过 "index.php" 时,会显示 404 错误。

我已经在我的控制器中尝试了 return $this->redirect('...')return new RedirectResponde('...'),但是浏览器只说重定向太多。

将 /hesk 和 /hesk/ 重定向到 /hesk/index.php 的正确方法是什么?

如果你使用 Apache,你可以在 /public/hesk/ 中放置一个 .htaccess 文件来强制重定向,类似这些:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*) index.php [L,QSA]
</IfModule>

或者直接在虚拟主机中使用 DirectoryIndex index.php 指令。

对于 Nginx,您需要修改虚拟主机以添加重定向。类似的东西(未测试):

location /hesk {
    try_files $uri $uri/ /index.php$uri&$args;
}