deex
#1
Hello,
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 :
https://pastebin.com/JRtcQZPa
This code works, the php extension is removed BUT the page is a 404 error
For example :
contact.php redirects to contact BUT the page displays a 404
Thank you for you help
Supun
#2
Can you please post the code you use?
deex
#3
Hello,
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
deex
#5
deex
#8
Hello
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
1 Like
AH I see now I’ll shut up and let someone else advise then
@teodor maybe
Try adding this to your htaccess
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
1 Like
deex
#12
It works ! Thank you very much
1 Like