聘我网

新概念招聘3.0

Symfony中的frontend_dev.php是怎么得到运行的?

vote up0vote downstar

.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>

当我们访问http://localhost/frontend_dev.php/1/2.php这样的uri时怎么就会被转到frontend_dev.php呢?

 

1 个答复

vote up0vote downcheck

很简单,因为Apache发现了文件http://localhost/frontend_dev.php的存在,/1/2.php就作为参数了(PATH_INFO

可以尝试访问http://51hired.com/index.php/2/3.php,其实访问的还是http://51hired.com/index.php,但里面的文件加载路径会错开就是了

PATH_INFO

Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff.

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.