当重定向 index.html 到 404 错误页面时,Apache 不加载任何页面
When redirect index.html to 404 error page, Apache doesn't load any page
我在 Apache 服务器和 Ubuntu 机器上托管了一个网站。当访问者键入 mydomain.com/index.html 我想将其重定向到自定义 404 页面错误。
所以在 /etc/apache2/sites-available
中,我按以下方式编辑 mydomain.com.conf
文件:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorDocument 403 /custom_403.html
ErrorDocument 404 /custom_404.html
Redirect 404 /index.html
但是现在当我键入 www.mydomain.com
时,Apache 既不加载 index.html
也不加载 custom_404.html
。相反,它显示了我在 DocumentRoot
.
中的文件夹结构
没有这个问题我怎样才能实现我的目标?
谢谢
我找到了一种方法来阻止用户通过写 mydomain.com/index.html
来访问该网站。我编辑了文件 /etc/apache2/mods-available/dir.conf
并在写入 DirectoryIndex
的行中将 index.html
更改为 somethingElse.html
。然后在 DocumentRoot
我也把 index.html
的名字改成了 somethingElse.html
。
我保留了文件 /etc/apache2/sites-available/mydomain.com.conf
的配置,因此每次用户键入 mydomain.com/index.html
时,它都会得到一个 404
错误自定义页面。
我在 Apache 服务器和 Ubuntu 机器上托管了一个网站。当访问者键入 mydomain.com/index.html 我想将其重定向到自定义 404 页面错误。
所以在 /etc/apache2/sites-available
中,我按以下方式编辑 mydomain.com.conf
文件:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorDocument 403 /custom_403.html
ErrorDocument 404 /custom_404.html
Redirect 404 /index.html
但是现在当我键入 www.mydomain.com
时,Apache 既不加载 index.html
也不加载 custom_404.html
。相反,它显示了我在 DocumentRoot
.
没有这个问题我怎样才能实现我的目标? 谢谢
我找到了一种方法来阻止用户通过写 mydomain.com/index.html
来访问该网站。我编辑了文件 /etc/apache2/mods-available/dir.conf
并在写入 DirectoryIndex
的行中将 index.html
更改为 somethingElse.html
。然后在 DocumentRoot
我也把 index.html
的名字改成了 somethingElse.html
。
我保留了文件 /etc/apache2/sites-available/mydomain.com.conf
的配置,因此每次用户键入 mydomain.com/index.html
时,它都会得到一个 404
错误自定义页面。