How to hide file ext from the URL .php .html

I want to hide the file ext exp .php .html from the URL and am doing it using .htacces file but the only problem is that by using this code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
the browser can’t read my website folders.
https://gamehup.com/flash-games/page-1
the flash games in the URL is a folder on my website and I want to make an index page for it to appear like this https://gamehup.com/flash-games/
but because of the rewrite code above am getting error page the only way to enter that page is by typing index after the folder name
https://gamehup.com/flash-games/
and that’s is not good for me does there any other way to hide the file
ext without changing anything on the website e.

**and thanks for help hope you got the idea **

Try

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

not working all my files now return 404 error page not found

Then try

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
1 Like