Forum Moderators: phranque

Message Too Old, No Replies

Env Vars & Rewrite

I can't get the syntax right to pass env vars

         

hmmm

6:22 pm on Mar 1, 2004 (gmt 0)

10+ Year Member



Hi,

I'd like to be able to add to my httpd.conf file the following functionality but try as i may i just can't even get close.

What i am trying to achieve is...

VirtualSite1 = the main site with some php programs

VirtualSite2..3..4 etc... = are slave sites that utilise the same programs but i need to post some extra vars with them.

I need tag=HTTP_HOST and id=HTTP_HOST to be sent via a rewrite as its not possible to edit the php due to support/upgrade issues.

The idea being that there is one set of php scripts that will know from Apache what tag and id have been set as it runs.

Any help on this would be most appreciated.

Thanx.. Steve :o)

jdMorgan

6:53 pm on Mar 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmmm,

Welcome to WebmasterWorld [webmasterworld.com]!

You haven't provided all the info I'd like to see, but here's something to start with:


RewriteRule .* - [ENV=tag:%{HTTP_HOST},ENV=id:%{HTTP_HOST},L]

This would be more efficient if you placed a pattern in the RewriteRule [httpd.apache.org] which matches only the script's URL, thus limiting the scope of the variables to situations where they are needed. For example:

RewriteRule ^your_script_name\.php$ - [ENV=tag:%{HTTP_HOST},ENV=id:%{HTTP_HOST},L]

These rules will set the environment variables "tag" and "host" to the value of the currently-requested hostname.

Jim

hmmm

7:13 pm on Mar 1, 2004 (gmt 0)

10+ Year Member



Great... that seems to be just the ticket!

Thanx very much :-)

hmmm

2:05 pm on Mar 2, 2004 (gmt 0)

10+ Year Member



Hi,

I thought i had this working last night but today i've checked it again and it's not... i guess i must have had a browser cache or something as once its set once it becomes a session var so it remembers.

The rule you posted was...
RewriteRule ^your_script_name\.php$ - [ENV=tag:%{HTTP_HOST},ENV=id:%{HTTP_HOST},L]

I've tried all combinations but cant seem to get it to be queried by the php...

What i need is "any" post whatsoever to the site to have the two env vars set by default.

Any ideas?

Steve :o)

PS: I'm using Apache 2.0 nit sure if this makes a diff?

jdMorgan

3:39 pm on Mar 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try the first one posted above...

Jim