在Ubuntu上自定义Apache错误页面,可按以下步骤操作:
/var/www/html/custom-errors
)下创建HTML文件,如404.html
、500.html
等,添加相应内容。/etc/apache2/sites-available/000-default.conf
或/etc/apache2/sites-available/your-site.conf
),在<VirtualHost>
块中添加ErrorDocument
指令,指定错误代码和自定义页面路径。/etc/apache2/conf-available/custom-error-pages.conf
文件,在其中添加ErrorDocument
指令,然后启用该配置文件。sudo systemctl restart apache2
。