I've been trying to make adding the '.php' file extension optional in URLs. So if I had an URL like 'www.example.com/page.php', 'www.example.com/page' would also work. And I managed to do it (this article and this StackOverflow question is where I tried to take solutions from).
Here for example is the solution I found on the article page:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
But there was a problem, because I had an URL that was like 'www.example.com/articles/index.php'. While 'www.example.com/articles/index' worked, 'www.example.com/articles' would no longer lead to the index page, even after I tried to add a DirectoryIndex (with values like 'index.php' or even just 'index').
Is there some other way to hide a file extension like '.php', while still making the index file work as intended?