rewrite - How does apache server work?
黄舟
黄舟 2017-05-16 17:03:29
0
1
496

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?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
为情所困

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template