Skip to main content
Participating Frequently
November 5, 2009
Question

Apache mod_rewrite CGI Variables in ColdFusion

  • November 5, 2009
  • 1 reply
  • 3161 views

I have an environment that consists of Apache 2.2.8 and ColdFusion 8 running on Solaris 10.

I am attempting to pass a CGI variable to ColdFusion as part of an Apache Rewrite rule, however I am not able to do so.

The Rewrite rule set exists as follows:

RewriteCond %{SSL:SSL_PROTOCOL} ^TLSv1$
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule ^.*$ %{HTTP_REFERER}?result=pass [L,R,E=HTTP_MYVAR:rw]

The rule set works with the exception of the availability of the CGI variable HTTP_MYVAR within the ColdFusion CGI scope.

I am testing for the existance of the variable within ColdFusion as follows:

<cfif (structkeyexists(cgi, 'CGI.HTTP_MYVAR'))>
   CGI.HTTP_MYVAR exists as:<cfoutput>#CGI.HTTP_MYVAR#</cfoutput>
<cfelse>
   CGI.HTTP_MYVAR does not exist.
</cfif>

Does anyone have experience creating variables in an Apache Rewrite rule set and evaluating them in ColdFusion?

Thanks in advance for any assistance.

This topic has been closed for replies.

1 reply

Inspiring
November 7, 2009

Does anyone have experience creating variables in an Apache Rewrite rule set and evaluating them in ColdFusion?

I didn't until trying to investigate this issue for you, but do now.  So cheers for that! :-)

Your problem, though, is nothing to do with MOD_REWRITE.  Have a look at this line of code:

<cfif (structkeyexists(cgi, 'CGI.HTTP_MYVAR'))>

Take a good close look at it...

--

Adam

dmalloyAuthor
Participating Frequently
January 18, 2010

Adam,

Thank you taking the time to look at this issue.

I have spent some time on this and I have not been successful in setting a variable in the Apache Rewrite rule and evaluating it within ColdFusion code.

Can you send me sample RewriteRule code and ColdFusion code if you have been successful in accomplishing this?

Thanks again.

Dave

Inspiring
January 18, 2010

Did you do what I suggested and have a good hard look at that CF code you posted?  And did you notice the mistake in it?

Your Apache settings are fine.  It's your CF code that's got a (reasonably obvious, once you look at it) mistake in it.

Think about the two parameters that structKeyExists() takes.  Have you got them right?  (hint: no).

--

Adam