I used this code
## remove the php extention
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This works for some files the e.g. example.com/contact
, but doesn't work when I have a .php
file that is also a directory. For example, in the root folder:
science.php
science - folder
The articles are in categories e.g. http://example.com/science/themost-blabla.php
- this works, the .php
extionsion doesn't appear in the URL.
So I want to know if is any possible to hide the .php
extension to science.php
because when I type example.com/science
... it redirects me to the content of the science folder....
Index of /science
directory:
afla-care-a-fost-primul-meci-televizat-de-fotbal-din-lume-1937-arsenal.php
cazinoul-din-constanta.php cele-7-minuni-ale-lumii.php
descoperire-colosala-a-epavei-navei-spaniole-san-jose-ce-avea-la-bord-o-avere-impresionanta.php
imagini/ mitologia-greaca.php poenaru.php
top-10-cele-mai-importante-inventii-romanesti-din-istorie.php
top-5-enigme-ale-lumii.php turnul-eiffel.php
So, can I do something to hide the extension to this page? Or do I need to change the name of the file - to not be the some as the folder?