为什么我的控制器在Symfony中请求frontend_dev.php?

use*_*729 4 php symfony1 controller

HTTP://localhost/frontend_dev.php/1

为什么上述请求被重定向frontend_dev.php而不是index.php

我读过.htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

如果我正确理解它,如果请求的文件不存在,应该重定向到index.php,如何frontend_dev.php在上面的情况下运行?

Rai*_*ise 6

您已将http://localhost/frontend_dev.php/1指定为URL - Apache只是frontend_dev.php在您明确要求URL中的文件时提供服务.将您的URL更改为http://localhost/index.php/1以查看生产控制器.

重写规则处理完全没有提到前端控制器的URL,即.http:// localhost/1 - 对于您最初提供的URL,根本没有解析重写规则,因为Apache检测到了frontend_dev.php文件,发现没有匹配的重写规则要解析.