首页 > 解决方案 > 当 url 只有扩展名而没有页面名称时,从禁止页面重定向到 404 页面

问题描述

访问没有扩展名的页面名称时,我面临 403 错误禁止消息。前任。http://loremipsum.lorem/.html节目403 forbidden.

.htaccess文件中使用

RewriteRule \.html$ - [R=404,L]

也用过

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ test.php?page=$1 [L]

每当有人尝试访问/.htmlor/.htm/.phpin 时url,网页应重定向到404页面或任何自定义页面(设置任何自定义页面而不是默认错误页面)。

标签: .htaccessredirect

解决方案


/.html 或 /.htm 或 /.php 不是有效地址,因此ErrorDocument 404 /404.html请在您的 .htaccess 文件中设置并使用您的自定义错误消息创建 /404.html 文件。


推荐阅读