gpt4 book ai didi

.htaccess - ErrorDocument 404 打印文件名

转载 作者:行者123 更新时间:2023-12-01 10:51:19 25 4
gpt4 key购买 nike

我有一个文件 index.php ,并在同一级别 .htaccess使用此代码:

ErrorDocument 404 index.php

当我生成未找到错误时,会打印一个带有文件名的页面,因此,在这种情况下,我只能看到 index.php作为文字。我想要的显然是重定向到主页。

对这个问题有什么想法吗?
www\site 
-index.php
-.htaccess

最佳答案

你要:

ErrorDocument 404 /index.php

ErrorDocument docs :

URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser. Examples:


ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today"

因此,如果它不是 FQDN 或以 / 开头的内容,假设您希望显示自定义消息。

关于.htaccess - ErrorDocument 404 打印文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19647917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com