I'm trying to automatically rewrite a URL to a virtual directory using .htaccess.
My rules are working but not automatically, so for example I have a file called login.php in the root directory and I want to rewrite to to a virtual directory to be like this example.com/login/ instead of example.com/login.php, the below rule works fine for this purpose.
RewriteOptions inherit
RewriteEngine On
RewriteBase /
RewriteRule ^login/$ ./login.php [L,NC]
However, this won't rewrite the login.php file automatically. I need whenever a user requests the login.php file, the rule automatically redirects the user to example.com/login/ and still serve the same content. How could this be achieved?