cacher l’extension de fichier dans l’URL par htaccess

Je souhaite masquer les extensions de fichier dans le navigateur pour les afficher, comme http://www.example.com/dir/abc.php et les afficher sous la forme http://www.example.com/dir/abc uniquement.

J’ai écrit suite à rewriteCond et réécrire la règle sur .htaccess

 Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ /$1.php [L,QSA] 

mais ce code ne semble pas m’aider.

EDIT: c’est le code complet de mon fichier htaccess

 Options -Indexes ErrorDocument 403 /errors/403.php ErrorDocument 404 /errors/404.php RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(www\.)?127.0.0.1 [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?127.0.0.1.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] RewriteRule \.(js|css|jpg|png)$ - [F] RewriteEngine on RewriteRule ^(.*)\.[\d]{10}\.(css|js|png|jpg)$ $1.$2 [L] RewriteEngine On # To externally redirect /dir/file.php to /dir/file RewriteCond %{THE_REQUEST} ^[AZ]{3,}\s/+(.+?)\.php[\s?] [NC] RewriteRule ^ /%1 [R=301,L,NE] 

COMPLET .htaccess:

 Options +FollowSymLinks -MultiViews ErrorDocument 403 /errors/403.php ErrorDocument 404 /errors/404.php RewriteEngine on # To externally redirect /dir/file.php to /dir/file RewriteCond %{THE_REQUEST} ^[AZ]{3,}\s/+(.+?)\.php[\s?] [NC] RewriteRule ^ /%1 [R=301,L,NE] # To internally forward /dir/file to /dir/file.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.+?)/?$ /$1.php [L] # block direct hot linking RewriteCond %{HTTP_REFERER} !^http://(www\.)?127.0.0.1 [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] RewriteRule \.(js|css|jpg|png)$ - [F] RewriteRule ^(.*)\.[\d]{10}\.(css|js|png|jpg)$ $1.$2 [L] 

Le moyen le plus simple et le plus simple:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [L] 
  RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule ^(.*)$ $1\.php 

Je ne suis pas un expert d’Apache, mais je suis curieux de savoir pourquoi personne ne recommande le module de négociation (mod_negotiation). Existe-t-il des raisons de bonnes pratiques pour éviter d’utiliser

J’en ai entendu parler en passant à http://www.webhostingtalk.com/showthread.php?t=317269 . Après avoir activé mod_negotiation dans ma configuration globale:

 LoadModule negotiation_module /usr/lib/apache2/modules/mod_negotiation.so 

Je devais juste l’activer dans les options de mon virtualhost. Voici le bloc de configuration entier:

 DocumentRoot /var/www/site_directory/public_html ServerName your.domain.here.com  allow from all Options +Indexes Multiviews  

méthode facile est:

 you create your link like 

'Home' au lieu de 'Home'
Alors votre .htaccess devrait être comme ceci:

 RewriteCond %(REQUEST_FILENAME) !-d RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-l RewriteCond ^https://stackoverflow.com/questions/19658158/hide-file-extension-in-url-by-htaccess/home https://stackoverflow.com/questions/19658158/hide-file-extension-in-url-by-htaccess/home.php [L]