/ / 404 page ne fonctionne pas pour les liens avec slash final - php, html, .htaccess, http-status-code-404

404 pages ne fonctionnant pas pour les liens avec slash final - php, html, .htaccess, http-status-code-404

J'ai un site avec une page d'erreur 404, configurée dans htaccess comme ceci:

ErrorDocument 404 http://www.example.com/error404.php

Cela fonctionne bien si vous essayez d'accéder à une page qui n'existe pas:

www.example.com/nonsensepage.php
www.example.com/nonsensepage.htm

Mais la recherche Google comporte d'anciens liens du site précédent (un site Joomla), au format suivant:

www.example.com/index.php/news

Et ce n'est pas pris par ma page 404. Au lieu de cela, il va à ma page d'index et brise la page!

Comment puis-je m'assurer que ma page 404 capture TOUS les URL erronées?

Merci


MODIFIER:

J'ai déjà essayé la réponse à la question en double, (pour ajouter AcceptPathInfo Off) mais cela ne semble pas fonctionner pour moi.

C'est tout ce que j'ai dans mon fichier htaccess:

DirectoryIndex index.php

AcceptPathInfo Off
CheckSpelling Off

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

FileETag none
ServerSignature Off

Options +FollowSymlinks

RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC]

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

ErrorDocument 404 http://www.example.com/error404.php

Je serais également heureux avec juste une solution qui dépouille tout contenu et barre oblique, dirigeant toujours:

index.php/anything

soit index.php ou error404.php

Réponses:

4 pour la réponse № 1

Vous pouvez ajouter cette ligne en haut de votre fichier .htaccess pour envoyer 404 après une barre oblique pour .php des dossiers:

AcceptPathInfo Off

Alternativement vous pouvez utiliser cette règle de réécriture:

RewriteEngine On

RewriteRule .php/.+$ [L,NC,R=404]