Mod-Rewrite
IE 不解釋 mod_rewrite 規則
我有一個非常簡單的
mod_rewrite
規則:<Directory "/local/foobar.com/"> RewriteEngine On RewriteBase / RewriteRule ^test$ hello/ [R] </Directory>
在 Chrome 中,當我轉到 時
www.foobar.com/test
,我被重定向到www.foobar.com/hello/
,但在 IE9 中,沒有發生重定向 - 我錯過了什麼?!更多資訊
根據評論中的要求,記錄輸出:
鉻合金:
192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (3) [perdir /local/foo.com/] strip per-dir prefix: /local/foo.com/test -> test 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (3) [perdir /local/foo.com/] applying pattern '^test$' to uri 'test' 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (2) [perdir /local/foo.com/] rewrite 'test' -> 'hello/' 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (3) [perdir /local/foo.com/] add per-dir prefix: hello/ -> /local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (2) [perdir /local/foo.com/] explicitly forcing redirect with http://foo.com/local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (2) [perdir /local/foo.com/] trying to replace prefix /local/foo.com/ with / 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (1) [perdir /local/foo.com/] escaping http://foo.com/hello/ for redirect 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420002978/initial] (1) [perdir /local/foo.com/] redirect to http://foo.com/hello/ [REDIRECT/302] 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420006998/initial] (3) [perdir /local/foo.com/] add path info postfix: /local/foo.com/hello -> /local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420006998/initial] (3) [perdir /local/foo.com/] strip per-dir prefix: /local/foo.com/hello/ -> hello/ 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420006998/initial] (3) [perdir /local/foo.com/] applying pattern '^test$' to uri 'hello/' 192.171.135.86 - - [16/Nov/2015:17:56:39 +0000] [foo.com/sid#7f4458ffddc8][rid#7f4420006998/initial] (1) [perdir /local/foo.com/] pass through /local/foo.com/hello
IE9:
192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (3) [perdir /local/foo.com/] strip per-dir prefix: /local/foo.com/test -> test 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (3) [perdir /local/foo.com/] applying pattern '^test$' to uri 'test' 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (2) [perdir /local/foo.com/] rewrite 'test' -> 'hello/' 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (3) [perdir /local/foo.com/] add per-dir prefix: hello/ -> /local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (2) [perdir /local/foo.com/] explicitly forcing redirect with http://foo.com/local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (2) [perdir /local/foo.com/] trying to replace prefix /local/foo.com/ with / 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (1) [perdir /local/foo.com/] escaping http://foo.com/hello/ for redirect 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f440c00a9b8/initial] (1) [perdir /local/foo.com/] redirect to http://foo.com/hello/ [REDIRECT/302] 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f44101b7688/initial] (3) [perdir /local/foo.com/] add path info postfix: /local/foo.com/hello -> /local/foo.com/hello/ 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f44101b7688/initial] (3) [perdir /local/foo.com/] strip per-dir prefix: /local/foo.com/hello/ -> hello/ 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f44101b7688/initial] (3) [perdir /local/foo.com/] applying pattern '^test$' to uri 'hello/' 192.171.135.86 - - [16/Nov/2015:18:01:45 +0000] [foo.com/sid#7f4458ffddc8][rid#7f44101b7688/initial] (1) [perdir /local/foo.com/] pass through /local/foo.com/hello
我終於意識到發生了什麼。我實際上沒有一個名為的文件夾
hello
- 我只是想測試一個抽象mod_rewrite
規則。無論返回任何 http 程式碼,Chrome 似乎都會遵循重定向,但如果隨後返回 404,IE 將不會顯示重定向。一旦我添加了一個名為 的文件夾
hello
,IE確實遵循了規則。