Home  >  Q&A  >  body text

rewrite - How does apache server work?

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?

黄舟黄舟2713 days ago476

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 17:05:29

    When accessing, it can be accessed directly through the folder path or through routing rule matching. I would like to ask in what order does apache distribute requests?

    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:

    1. Direct access through the folder path indicates that Apache has found this "static file", which is the target php file.

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

    reply
    0
  • Cancelreply