Mod-Rewrite
Mod_Rewrite 錯誤程式碼:ERR_TOO_MANY_REDIRECTS
我知道很多人都發布了關於這個錯誤的文章,但是我仍然無法解決它。所以這就是我用它開始新文章的原因。
如標題所述,我在訪問網站中的頁面時遇到了重定向循環。
這是我的重寫配置。
RewriteCond %{HTTP_REFERER} ^http://example\.com/test/store\.do [NC] RewriteRule (.*)$ /test/$1 [R]
那麼,我該如何解決這個重定向錯誤呢?
[Fri May 16 12:18:20.345204 2014] [rewrite:trace3] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] applying pattern '(.*)$' to uri '/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test/ /store.do', referer: http://example.com/test/store.do [Fri May 16 12:18:20.345213 2014] [rewrite:trace4] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] RewriteCond: input='http://example.com/test/store.do' pattern='^http://example\\.com/test/store\\.do' [NC] => matched, referer: http://example.com/test/store.do [Fri May 16 12:18:20.345218 2014] [rewrite:trace2] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] rewrite '/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//whatshot_v3/hahah/store.do' -> '/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//store.do', referer: http://example.com/test/store.do [Fri May 16 12:18:20.345233 2014] [rewrite:trace2] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] explicitly forcing redirect with http://example.com/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test/ /store.do, referer: http://example.com/test/store.do [Fri May 16 12:18:20.345239 2014] [rewrite:trace1] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] escaping http://example.com/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//store.do for redirect, referer: http://example.com/test/store.do [Fri May 16 12:18:20.345245 2014] [rewrite:trace1] [pid 29462:tid 1193511232] mod_rewrite.c(475): [client 172.16.28.96:60187] 172.16.28.96 - - [example.com/sid#1e84d1c0][rid#1e954910/initial] redirect to http://example.com/test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//test//store/store.do [REDIRECT/302], referer: http://example.com/test/store.do
這是我的日誌文件。
謝謝。
如果可能,最好的解決方案可能是更改對其他資源的引用以包含
/test/
而不是在 mod_rewrite 中修改它。但是,這應該有效:
RewriteCond %{HTTP_REFERER} ^http://example\.com/test/store\.do [NC] RewriteRule ^/test - [L] RewriteCond %{HTTP_REFERER} ^http://example\.com/test/store\.do [NC] RewriteRule ^/(.*)$ /test/$1 [L]
請注意,它不是重定向,因為沒有理由讓客戶端為每個資源發送額外的請求,儘管這仍然可以工作。