'CodeIgniter routing rules

I am a junior PHP developer. I am experiencing some confusion when using the CodeIgniter framework. When I use the Apache server under xampp, I have to set route rules for each controller; otherwise, the site cannot find the URL.

However, when I was using Nginx, I followed a tutorial on the web and set up the /etc/nginx/frameworks-enabled/php.conf file with a statement like this.

location /demo {
try_files $uri $uri/ /demo/index.php;
index index.php;
}.

Then I found that even if I only use the reserved routes rule in config/routes.php, and I can still get to the URL of each new controller without any problems.

I will give more details. For example: When I use Apache, I must add $route['New'] = 'new' if I want to add a new controller such as New.php. And I need to repeat the step for each other controllers. However, I do not need to repeat this step when I use Nginx if I set up the above code in the server.

What is the reason for this, and how can I get Apache to do the same thing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source