I have a Laravel 5 project with routes set up as well as a custom 404 page (mostly for missing/incorrect "pages").

So basically if I open any existing route I get the correct output and every other URL is showing the 404:

project.com/login - Fine, login page

project.com/ghdkfgl - 404

This looks clear and seems to be working as expected. So anything I add after the slash opens either an actual existing page or a 404 page.

Unless I put a 'index.php' anywhere in the URL. In this case, Laravel is executing the request for some reason like this:

project.com/jhdfkds/index.php/login - Opens the login page (the CSS and other resources are gone because of the paths but that's clear).

project.com/kfhjdsg/index.php/fkdhsg - Opens a 404 (but the CSS and other resources are not loaded too).

I'm sure both of these should open the 404 since there's no such routes in my project.

I also checked for the same behavior on the Laravel documentation website (I assume its built on Laravel).

http://laravel.com/docs/5.0 - Actual URL

http://laravel.com/aaa - A nice 404 page

http://laravel.com/aaa/index.php/docs/5.0 - Laravel documentation page again, same as the first one

What might be causing this? How can this be solved?

Why would Laravel even consider the 'index.php' in the middle of the URL?

Does this have anything to do with the .htaccess file? (I didn't edit it though)