Forum Moderators: phranque

Message Too Old, No Replies

Can't get environment variables to work

         

miyazaki

4:25 pm on Dec 30, 2008 (gmt 0)

10+ Year Member



Hello,

I seem to have a gaping hole in my knowledge of how environment variables work. Here's my test .htaccess script:


RewriteEngine on
RewriteRule ^a.html$ b.html [ENV=myenvvar:testval]
RewriteRule ^b.html$ hello${ENV:myenvvar}there.html [L]

When I go to the page a.html, I expect to land up at a page called 'hellotestvalthere.html'. But instead I just end up at 'hellothere.html', and the environment variable I set is completely ignored.

I'm using Apache 2.2, and appear to be seriously underinformed! What am I doing wrong? Thanks!

jdMorgan

4:35 pm on Dec 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the syntax on your envar reference in the substitution URL-path of the second rule...

Jim

miyazaki

4:46 pm on Dec 30, 2008 (gmt 0)

10+ Year Member



Lol, thanks. %, not $. Knew I'd blush when I found out...

jdMorgan

5:15 pm on Dec 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With mod_rewrite, it's often the "little things" that get you -- As we often warn readers here... :)

Glad you got it sorted.

Jim