.htaccess - 当 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]
每当有人尝试访问/.html
or/.htm
或/.php
in 时url
,网页应重定向到404
页面或任何自定义页面(设置任何自定义页面而不是默认错误页面)。
解决方案
/.html 或 /.htm 或 /.php 不是有效地址,因此ErrorDocument 404 /404.html
请在您的 .htaccess 文件中设置并使用您的自定义错误消息创建 /404.html 文件。
推荐阅读
- javascript - 如何从 SuccessFactors Career(招聘)网站获取 CandidateID?
- c++ - 如何使用 XDevAPI 将结果从 Row 存储到字符串对象
- java - 我需要有关 Android 上的 Geofence 或 Geofire 的帮助
- php - 页面重定向问题codeigniter:404错误
- css - 标题 div 的背景颜色不起作用
- pulumi - 创建注册表后如何将 docker 映像推送到 ECR?
- java - Switch Case 语句或其替代 If Condition 在 android 中不起作用
- android - 谷歌警告开发者为 Android 应用程序包含 64 位版本
- java - 我的 switch 语句没有返回任何东西?
- angular - 如何为两个单词标题中的单个单词赋予单独的颜色