Nettoyer les URL avec l’utilisation de .htaccess ou non

Hier, j’ai posté une question sur le fichier .htaccess. Maintenant, ça marche, mais j’ai un autre problème. Par exemple:

Quand j’essaye d’aller à “localhost / about”, ça ne marche pas, ça me donne une “erreur 404”:

Pas trouvé

L’URL / Applications / MAMP / htdocs / user / enric / n’a pas été trouvée sur ce serveur.

Mais quand je vais à “localhost / about /” ça marche. Pourquoi?

Je veux que les deux URL fonctionnent. Quelqu’un peut-il m’aider?

Ceci est le code de mon fichier .htaccess:

 Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteRule ^channels/page/([0-9]+)/?$ channels/index.php?p=$1 [L] RewriteRule ^channels/([_0-9a-z-]+)/?$ channels/index.php?o=$1 [L] RewriteRule ^channels/([_0-9a-z-]+)/([0-9]+)/?$ channels/index.php?o=$1&p=$2 [L] # User profiles RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1 [L] # Check to see if the URL points to a valid file RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Trailing slash check RewriteCond %{REQUEST_URI} !(.*)/$ # Add slash if missing & redirect RewriteRule ^(.*)$ $1/ [L,R=301] # Delete ".php" extension and adds "/" RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php RewriteRule (.*)\.php$ /$1/ [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteCond %{DOCUMENT_ROOT}%1.php -f RewriteRule (.*)/$ $1.php [L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule .*[^/]$ $0/ [L,R=301]  

Merci!

Essayez ce code légèrement modifié dans votre DocumentRoot/.htaccess :

 Options +FollowSymLinks -Multiviews RewriteEngine On RewriteRule ^channels/page/([0-9]+)/?$ channels/index.php?p=$1 [L] RewriteRule ^channels/([_0-9a-z-]+)/?$ channels/index.php?o=$1 [L] RewriteRule ^channels/([_0-9a-z-]+)/([0-9]+)/?$ channels/index.php?o=$1&p=$2 [L] # User profiles RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1 [L] # Check to see if the URL points to a valid file RewriteCond %{REQUEST_FILENAME} !-f # Trailing slash check RewriteCond %{REQUEST_URI} !(.*)/$ # Add slash if missing & redirect RewriteRule ^(.*)$ $1/ [L,R=301] # Delete ".php" extension and adds "/" RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{THE_REQUEST} \s/[^?\s]+\.php RewriteRule (.*)\.php$ /$1/ [L,R=301] RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteCond %{DOCUMENT_ROOT}%1.php -f RewriteRule (.*)/$ $1.php [L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]