如何在没有.php扩展名的情况下通过php脚本路由?

I've uploaded a php script to my online server, how can I route to pages without using .php extension?

The script is running on AWS, Ubuntu 18, PHP 7.2.19, Apache 2.4.29 I've tried to use .htaccess, installed and enableed mod_rewrite, but it didn't work.

.htaccess file:

IndexIgnore * # prevent directory listing

Order deny,allow
Allow from *

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

apache2.conf file:

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

when i route to file like "https://domainname.com/login", I expect to load "login.php" file, which resides in the root application folder, but instead I get 404 not found error:

Not Found
The requested URL /login was not found on this server.

and when navigate to "https://domainname.com/login.php", it works fine.