在 Apache 中进行重定向很容易 (mod_alias):
RedirectMatch ^.*$ http://portal.example.com/
Run Code Online (Sandbox Code Playgroud)
设置缓存标头同样简单:
Header set Cache-Control max-age=0
Header set Expires "Thu, 01 Dec 1994 16:00:00 GMT"
Run Code Online (Sandbox Code Playgroud)
(我不想缓存这个)
但!好像不能把两者结合起来。此配置导致发送重定向,但不发送标头:
<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>
Run Code Online (Sandbox Code Playgroud)
实际发生的例子:
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/ …
Run Code Online (Sandbox Code Playgroud)