What you are seeing is default behaviour on Apache.
when I enter random subdirectories, such as /index.php/asdfghjk
/asdfghjk
is an additional path-segment in the URL. It's not strictly a "subdirectory". (Directories and subdirectories relate to a filesystem. The URL does not necessarily map directly to the filesystem.)
When additional path segments occur after a valid file (that maps to the filesystem) in the URL, it is called additional pathname information (or path-info), and is accessible with the PHP superglobal $_SERVER['PATH_INFO']
in your PHP script.
On Apache, whether path-info is valid in the URL or not is (by default) dependent on the handler that handles the requested resource. In this case, the PHP handler allows path-info by default, so no 404, and /asdfghjk
is passed to index.php
to be handled by your script (some CMS use this URL pattern to create "pretty URLs" without having to resort to URL rewriting). On the other hand, the text/html
handler does not allow path-info, so /index.html/asdfghjk
would result in a 404 by default, unless you explicitly enable it.
To disable path-info for all requests, you can set the following at the top of the .htaccess
file.
AcceptPathInfo Off
The previous owner of the domain used joomla and the old site was structured in a way that all pages were subdirectories of /index.php
. Could this have something to do with my problem, even though I am no longer using a CMS?
No, this has nothing to do with Joomla. The "problem" exists regardless. Although if you are seeing many such requests in your logs then this will now doubt be because of the old URL structure. Any old URLs should be 301 redirected to the corresponding new URL (if any) in order to preserve SEO.
If they used Joomla, then they didn't need to use index.php
in the URL at all (unless there was a restriction with the web host).