I am using apache + phalcon (PHP framework) and configured the routing rules of the framework. When accessing, it can be accessed directly through the folder path or through routing rule matching. I want to understand how Apache handles these requests. What is the underlying implementation principle?
In these two cases, there is no problem of distributing requests, because these are two different requests in themselves.
For this request of routing rules, Apache will first search for
.htaccess
配置文件,找到之后读取其中的信息。在本项目中,.htaccess
中写的应该是非静态文件全部指向index.php
in the project root directory.Back to your question:
Direct access through the folder path indicates that Apache has found this "static file", which is the target php file.
Accessed through the URL matching the routing rules, Apache will find that the static file does not exist, and will point the request to
index.php
. At this time, the request will be taken over by the PHP code to match the routing rules and process the page.