我拥有的 .htaccess 文件无法在名为“error”的子文件夹中找到我的 404.html 文档。该行特别是:
ErrorDocument 404 /error/404.html
但是,如果我将 404.html 放在与 .htaccess 相同的目录中并将该行更改为:
ErrorDocument 404 /404.html
- - 有用!
如果有帮助,我将使用XAMPP for Windows,并且在我的 httpd.conf 文件中,相关指令设置如下(我意识到存在一些冗余):
<Directory />
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI MultiViews
AllowOverride All
Require all granted
</Directory>
此外,我的DocumentRoot设置为“C:/xampp/htdocs”,并且我尝试了各种路径来访问“错误”目录——没有任何工作:
ErrorDocument 404 /error/404.html
ErrorDocument 404 /flchi/error/404.html
ErrorDocument 404 /sites/flchi/error/404.html
ErrorDocument 404 /htdocs/sites/flchi/error/404.html
哦,最后一件事是值得的——我正在使用虚拟主机。以下是相关位:
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost flchi.local>
DocumentRoot "C:/xampp/htdocs/sites/flchi"
ServerName flchi.local
ServerAlias flchi.local
<Directory "C:/xampp/htdocs/sites/flchi">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>