是否可以使用自定义的406页面而不是默认页面?

时间:2018-08-27 02:35:07

标签: .htaccess

我在.htaccess的最后一行有这个

# Default response
RewriteRule ^.*$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/406.html [R=406,L]

但是当我测试时,它似乎返回了默认的Apache服务器页面。

$ curl -H "Accept: anything else" http://150.203.213.249/test
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   336  100   336    0     0    336      0  0:00:01 --:--:--  0:00:01  328k<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /test could not be found on this server.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 150.203.213.249 Port 80</address>
</body></html>

这旨在用作an entry to w3id.org

但是,我可以将代码更改为308,以使其重定向,这是不好的做法还是没关系?

1 个答案:

答案 0 :(得分:0)

您可以仅使用ErrorDocument指令为406(或408)呈现自定义页面:

ErrorDocument 406 /error.html