我的httpd.conf文件中有一个Apache 301redirect,它将所有stream量redirect到一个单一的域以进行规范化处理。 我最近注意到这个redirect不会保留标题中的引用。 RFC2616似乎表明在redirect时保留引用者是可选的,并且实际上在HTTP和HTTPS之间穿越时build议使用引用者。
虽然,我发现其他问题 ,其中一个简单的Apache 301redirect保留引荐,这通常是默认的情况下。 什么是可能影响这种行为的其他因素,我可以用来保护引用者? 是基于Apache服务器版本和/或客户端浏览器设置的唯一因素(IE。在我的控制之外)?
我的redirect:
ServerAlias www.example.com sub1.example.com ## Redirect all sub-domains to www RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
关于上面的重写规则,我正在访问http://sub1.example.com 。 我现在只是简单地使用HTTP,直到我能弄明白为止。
我确定引用链接的方式并没有被结转,只能通过浏览器手动访问redirect的网站,并打开开发者工具。 我也确定引用不包含在PHP的$_SERVER全球接收页面上。 我可以确认只有1个redirect发生。 服务器端语言是PHP。
这是初始页面(sub1.example.com)的请求标题:
GET / HTTP/1.1 Host: sub1.example.com Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Upgrade-Insecure-Requests: 1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8
以下是初始页面(sub1.example.com)的响应标题:
HTTP/1.1 301 Moved Permanently Date: Wed, 04 Oct 2017 18:14:34 GMT Server: Apache Upgrade-Insecure-Requests: 0 Location: http://www.example.com/ Cache-Control: max-age=1 Expires: Wed, 04 Oct 2017 18:14:35 GMT Content-Length: 243 Keep-Alive: timeout=5, max=99 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8
这是接收页面(www.example.com)的请求标题:
GET / HTTP/1.1 Host: www.example.com Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Upgrade-Insecure-Requests: 1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8 Cookie: <redacted>
接收页面的响应标题(www.example.com):
HTTP/1.1 200 OK Date: Wed, 04 Oct 2017 18:14:34 GMT Server: Apache Upgrade-Insecure-Requests: 0 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Vary: Accept-Encoding Content-Encoding: gzip Keep-Alive: timeout=5, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8
redirect(301)或其他方式将响应发送回客户端(用户的浏览器),其简单地表示“再次发送您的请求,但是这次使用foo.com”。 如果客户端select再次发送,那么它就会发送,而如何制定请求完全取决于客户端。 因为服务器端没有任何操作,所以不能影响引用者的包含。