У меня есть простой корень, который не работает без / Так что http://example.com/app выдает ошибку:
ResourceNotFoundException NotFoundHttpException HTTP 404 не найден Не найден маршрут для "GET / app"
, но если я сделаю http://example.com/app/ (я добавил '/' в конце URL), маршрутизатор работает.
Маршрутизатор:
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index()
{
return $this->render('index/index.html.twig', [
'controller_name' => 'IndexController',
]);
}
}
Чего мне не хватает?проблема в конфигурации nginx?
server {
listen 80;
server_name ~^(?<folder>[^.]*).magana.dev.example.fr;
charset utf-8;
index index.php index.html index.htm;
set $symfonyRoot /var/www/projects/dev/magana/$folder/htdocs/app/public;
set $symfonyScript index.php;
root /var/www/projects/dev/magana/$folder/htdocs;
access_log /var/www/projects/dev/magana/$folder/access.log;
error_log /var/www/projects/dev/commons/logs/magana_error.log;
client_max_body_size 200M;
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$ {
access_log off;
log_not_found off;
expires 30d;
add_header Pragma "public";
}
location /app {
root $symfonyRoot;
rewrite ^/app/(.*)$ /$1 break;
try_files $uri @symfonyFront;
}
location @symfonyFront {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $symfonyRoot/$symfonyScript;
fastcgi_param SCRIPT_NAME /app/$symfonyScript;
fastcgi_param REQUEST_URI /app$uri?$args;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV magana;
include fastcgi_params;
fastcgi_read_timeout 600;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SERVER_NAME $folder.magana.dev.example.fr;
}
location ~ /\.ht {
deny all;
}
}