Remove extension .php (htaccess)



I would like to remove extension .php from my free website.
On OVH my code in the htaccess file works but not here.

This is my htaccess file :

This code works, the php extension is removed BUT the page is a 404 error :frowning:

For example :
contact.php redirects to contact BUT the page displays a 404

Thank you for you help


Can you please post the code you use?



Thank you for your answer !
Here is my code :

RewriteEngine on
# Pour supprimer le slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L]
# Suppression de l'extension php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC]
RewriteRule ^ %1 [R=301,L]
## Redirection du index vers /
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} /index.(htm|html|php)$
RewriteCond %{THE_REQUEST} /index.(htm|html|php)
RewriteRule ^(.*)index.(htm|html|php)$ /$1 [R=301,L]
RAW Paste Data


Your website please.



#6 doesn’t exist that is why…?



Contact.php exists. With URL rewriting it’s possible to remove the php extension and call contact (whitout .php)

PS : this code works on OVH

Thank you


AH I see now I’ll shut up and let someone else advise then :stuck_out_tongue:

@teodor maybe


Thank you Infinity ! :smile:


Try adding this to your htaccess

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]


It works ! Thank you very much