小编Jak*_*org的帖子

Apache 重定向并设置缓存标头?

在 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)

configuration cache redirect http-headers apache-2.2

10
推荐指数
1
解决办法
1万
查看次数