清除Url错误404


Clean Url Error 404

只是想自定义错误404在我的htaccess。问题是当用户进入错误404页面时。与其他URL相比,URL不干净。URL看起来像index。php?页面=页面找不到. .我怎么做http://example.com/page-not-found.htm或http://example.com/page-not-found/??顺便,看看我的代码。

Options All -Indexes
RewriteEngine On
ErrorDocument 404 http://example.com/index.php?page=page-not-found
RewriteRule ^([^/]*)'.htm$ /website/index.php?page=$1 [L,QSA]
RewriteRule ^([^/]*)/lesson/([^/]*)'.htm$ /thesis/index.php?page=$1&lesson=$2

有什么想法吗?顺便说一下,谢谢……

从您的404指令中删除http://,以避免服务器对404进行完全重定向:

Options All -Indexes
RewriteEngine On
ErrorDocument 404 /index.php?page=page-not-found
RewriteRule ^([^/.]+)'.htm$ /website/index.php?page=$1 [L,QSA]
RewriteRule ^([^/]+)/lesson/([^/.]+)'.htm$ /thesis/index.php?page=$1&lesson=$2 [L,QSA]
Please try this one.First remove your extensions from all files and try this one
    ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^p/([0-9]+)$ /p.php?photo=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(Joe|Mao|Napoleon|Gandi)$ /profile.php?username=$1 [QSA,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ /$1.php [QSA,L]