开发者

Why is my controller requesting frontend_dev.php in Symfony?

http://localhost/frontend_dev.php/1

Why is the above request redirected to frontend_dev.php instead of index.php?

开发者_开发百科

I've read the .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>

If I'm understanding it correctly,if the requested file doesn't exist,it should be redirected to index.php,how can frontend_dev.php be run in the case above?


You have specified http://localhost/frontend_dev.php/1 as the URL - Apache simply serves up frontend_dev.php as you are explicitly asking for that file in the URL. Change your URL to http://localhost/index.php/1 to see the production controller.

The rewrite rules deal only with URLs that don't mention a front controller at all, ie. http://localhost/1 - the rewrite rules are not being parsed at all for the URL you initially provided, as Apache detected the frontend_dev.php file and found no matching rewrite rule to parse.


Simple. Because frontend_dev.php does exist, it is executed. And no redirect is performed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜