开发者

mod_rewrite not setting variables when I rewriterule

I think this is specific to me, but I want to redirect a user to an alternate image when the requested one does not exist. This part works. I also want to set an enviromental variable to turn the cache off for this one image, which is what I am having trouble with. My flag E=to set an enviromental variable is not working. I have apache2.2

In my rewrite log, I am getting this xx.xx.xx.xx - - [20/Jul/2011:09:57:24 --0500] [xx.xx.xx.xx/sid#86cad58][rid#89dde90/initial] (5) setting env variable 'devel' to '1'

When I try to print this variable using a header function, it comes out as (null). ie: debugger hello_(null)

if I set it using SetEnv directive, it sets the variable, but RewriteRule does not chanage the variable. My conditional header statements never print unless I set the variable using this method.

Here is my .htaccess

Order deny,allow
Deny from all
Allow from xx.xx.xx.xx

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*\.jpg$ /product.jpg [L,E=devel:1]

header always set cache-control "no-cache" env=devel
header always unset expires env=devel
header always add debugger "hello_%{devel}e"

OK, I think I might have bug in my apache build.

xx.xx.xx.xx - - [20/Jul/2011:14:24:12 --0500] [xx.xx.xx.xx/sid#4b60d58][rid#4e6eeb0/initial] (5) setting env variable 'devel' to '1' does not change the enviromental variable even though it says it does. xx.xx.xx.xx - - [20/Jul/2011:14:24:12 --0500] [xx.xx.xx.xx/sid#4b60d58][rid#4e7f3a0/initial/redir#1] (5) setting env variable 'devel' to '1' does change it. Notice the redir#1 in the second log开发者_开发百科 entry. I get this accomplished with this rule RewriteRule ^.*product.jpg$ - [L,E=devel:1] but it seems to run it on every request, so I am concerned about a performance hit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜