【发布时间】:2021-11-20 12:09:04
【问题描述】:
我正在使用自定义错误处理系统。
例如.htaccess文件命令:
ErrorDocument 404 /error-deal.php?code=404
error-deal.php 文件存在,如果我直接输入 URL,它会处理 $_GET 变量。
带有文件扩展名的页面不会触发.htaccess 重定向到错误页面:
https://example.com/does-not-exist.php
但没有扩展名的 URL 可以...
https://example.com/does-not-exist
我在这里错过了什么?
其他重写规则有:
#force https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
#redirect all www to non www
RewriteCond %{HTTP_HOST} ^www.donbur.co.uk$
RewriteRule (.*) https://donbur.co.uk/$1 [R=301,L]
#URL re-writes for dynamic pages
#to handle all news requests
RewriteRule ^news/([^/]*)$ /gb-en/news/article.php?title=$1 [L]
#to handle all feature requests
RewriteRule ^features/([^/]*)$ /gb-en/features/feature.php?title=$1 [L]
【问题讨论】:
-
您的 Apache 配置或 htaccess 中是否有任何重写规则?如果是这样,请也显示出来。
-
@MagnusEriksson 谢谢 - 我已经添加了我能找到的唯一条件和规则。
-
"带有文件扩展名的页面" - 具体来说,它似乎只有
.php扩展名。这可能与您系统上安装 PHP 的方式有关。例如,如果所有*.php请求都代理到备用服务器/进程,那么这将绕过应用服务器上的.htaccess文件。 -
谢谢@MrWhite。遗憾的是,我们无法控制此共享服务器,也无权访问配置文件。
标签: php .htaccess error-handling