Doc*_*iki 7 linux redirect errordocument http-status-code-404 apache-2.2
我想用 Apache 进行 404 重定向,我找到了几种解决方案:
.htaccess 方法。但如果没有必要,我不想添加 .htaccess。
虚拟主机方法:
Run Code Online (Sandbox Code Playgroud)<VirtualHost *:80> ServerAlias *.example.com Redirect 404 /index.html ErrorDocument 404 /index.html </VirtualHost>
我想知道 Redirect 404 和 ErrorDocument 404 有什么区别?
qua*_*nta 12
你用Redirect
指令测试了吗?
Redirect 404 /index.html
意味着 404 响应将在客户端请求时返回/index.html
(即使它可能存在)。
ErrorDocument 404 /index.html
意味着当客户端访问一个不存在的 URL 时,Apache 将重定向到 index.html 页面。
ErrorDocument
在这种情况下,您必须使用。