在Apache中进行重定向很容易(mod_alias):
RedirectMatch ^.*$ http://portal.example.com/
设置缓存头同样容易:
Header set Cache-Control max-age=0
Header set Expires "Thu, 01 Dec 1994 16:00:00 GMT"
(我不希望这个被缓存)
但!看来您无法将两者结合起来。此配置导致发送重定向,但不发送标头:
<VirtualHost *:80>
ServerName __default__
Header set Cache-Control max-age=0
Header set Expires "Thu, 01 Dec 1994 16:00:00 GMT"
RedirectMatch ^.*$ http://portal.example.com/
</VirtualHost>
实际情况的示例:
jb@apto % telnet 192.168.0.1 80
Trying 192.168.0.1...
Connected to redirector.example.com.
Escape character is '^]'.
GET / HTTP/1.1
Host: foo
HTTP/1.1 302 Found
Date: Sat, 21 Aug 2010 09:36:38 GMT
Server: Apache/2.2.9 (Debian) Phusion_Passenger/2.2.9
Location: http://portal.example.com/
Vary: Accept-Encoding
Content-Length: 316
Content-Type: text/html; charset=iso-8859-1
(etc)
关于如何返回带有缓存头的重定向的任何想法?