我ahve使用Apache httpd的2.2.15(Unix的)的mod_rewrite重寫規則,RewriteMap指令,設置Cookie的工作嚴重在一起
我有這樣的重寫goingon:
RewriteEngine On
RewriteLogLevel 7
RewriteMap encode-map prg:/var/www/centos6.local/encode.pl
RewriteLog "/var/log/httpd/centos6.local-rewrite_log"
RewriteCond %{QUERY_STRING} CID=(.*)
RewriteRule .* - [L,CO=NDD_COOKIE:${encode-map:%1}:ndipiazza.test.local:50000]
這樣做的目的是,如果你發現在查詢字符串的任何位置找到一個CID = xyz。如果你這樣做,創建一個xyz編碼的NDD_COOKIE自定義perl腳本/var/www/centos6.local/encode.pl
這隻會設置一次cookie,然後不會再次設置cookie,直到服務器重新啓動完全。
0)設置Hosts文件,以便ndpiazza.test.local指向192.168.2.7
1)啓動http://ndipiazza.test.local/test.html?CID=test123
結果:預期
2)切換到新的編碼cookie被寫入瀏覽器或清除瀏覽緩存。
3)啓動http://ndipiazza.test.local/test.html?CID=new567
結果:無Cookie是!
Here is a link to the encode.pl script
爲什麼會發生這種情況?
這裏是重寫日誌http://ndipiazza.test.local/test.html?UID=sfsfsfd888m當它不工作:在啓動Apache HTTPD
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (2) init rewrite engine with requested uri /test.html
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (3) applying pattern '.*' to uri '/test.html'
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (4) RewriteCond: input='UID=sfsfsfd888' pattern='UID=(.*)' => matched
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (5) map lookup OK: map=encode-map key=sfsfsfd888 -> val=
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (5) setting cookie 'WS_CUID=ndipiazza.test.local; path=/; domain=50000'
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (1) pass through /test.html
你可能是正確的。 ..但我認爲prg應該調用perl程序一次,並讓它開放,聽取輸入。我也會嘗試。 –