使用子目录中的404 ErrorDocument [英] Use 404 ErrorDocument that is in a sub directory
问题描述
我在子文件夹中有一个htaccess文件,如下所示:
I have a htaccess file in a sub folder like so:
/subfolder/.htaccess
在htaccess文件中,以下代码设置404错误文档
In the htaccess file the following code to set a 404 ErrorDocument
ErrorDocument 404 /404.php
问题是404页将加载根目录中的文件,而不是 / subfolder /
文件夹中的文件。我不能简单地将htaccess文件更改为使用/subfolder/404.php,因为该系统将安装在许多不同的地方。
The issue is the 404 page in the root directory is loaded rather than the one in the /subfolder/
folder. I can't simply change the htaccess file to use /subfolder/404.php because the system is going to be installed in lots of different places.
有没有办法引用htaccess所在目录中的文件?
Is there a way to reference the files in the directory that the htaccess is in?
推荐答案
我只是遇到了同样的问题,找到了您的页面。如果您具有域/文件夹,并且想要将任何内容从文件夹重定向回到域的索引,请使用 ErrorDocument 404 /
I just had the same problem and found you page...If you have domain/folder and want to redirect anything from the folder back to the domain's index, use ErrorDocument 404 /
...我不确定这是进入根文件夹还是向上一个文件夹,但就您而言(和我的情况),它们是相同的。
...I'm not sure if this goes to the root folder or one folder up, but in your case (and mine) they are one in the same.
希望这会有所帮助!
这篇关于使用子目录中的404 ErrorDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!