我在 linux 环境中运行 apache2 网络服务器。我想将用户重定向到自定义错误页面。所以创建了错误页面并在 htdocs 中创建了符号链接,也是这样。静态文件-> /app/静态文件。在 httpd.conf 文件中,我创建了虚拟主机定义并包含错误页面,如下所示:
NameVirtualHost m.mydomain.com:80
<VirtualHost m.mydomain.com:80>
DocumentRoot "/app/httpd-2.2.15/htdocs"
ServerName m.mydomain.com:80
<Directory "/static-files/html/error_pages">
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
ErrorLog /app/httpd-2.2.15/logs/error_my_log
ErrorDocument 400 /static-files/html/error_pages/error_400.html
ErrorDocument 401 /static-files/html/error_pages/error_401.html
ErrorDocument 403 /static-files/html/error_pages/error_403.html
ErrorDocument 404 /static-files/html/error_pages/error_404.html
ErrorDocument 408 /static-files/html/error_pages/error_408.html
ErrorDocument 500 /static-files/html/error_pages/error_500.html
ErrorDocument 501 /static-files/html/error_pages/error_501.html
ErrorDocument 502 /static-files/html/error_pages/error_502.html
ErrorDocument 503 /static-files/html/error_pages/error_503.html
ErrorDocument 504 /static-files/html/error_pages/error_504.html
</VirtualHost>
当我的应用服务器关闭时,它不会将我重定向到 503 自定义错误页面。我只获取服务器特定的错误页面。但是如果我将此 ErrorDocument 放在虚拟主机定义之外,它会将我重定向到自定义错误页面。我打了三天头。但找不到原因。我在所有浏览器中都试过了。有人可以帮助我吗?