Apache mod_rewrite CGI Variables in ColdFusion

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.

OK, as part of my work-avoidance for the day, I have replicated the work I did in NZ on my other laptop.
I put this in httpd.conf
Alias /junk C:/webroots/junk
<Directory "C:/webroots/junk">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    RewriteEngine  on
    RewriteBase    /junk/
    RewriteRule (.*) $1 [E=MYCUSTOMVARIABLE:mycustomvalue]
</Directory>
And my test code is this:
<cfoutput>
CGI.MYCUSTOMVARIABLE = [#CGI.MYCUSTOMVARIABLE#]<br />
</cfoutput>
I restart Apache, run the template, and I get this:
CGI.MYCUSTOMVARIABLE = [mycustomvalue]
How does this differ from what you're doing?
Adam

Similar Messages

  • Using owa_util.get_cgi_env to get a cgi variable

    Using Forms 10g, on a UNIX server, I am trying to call this function: get_cgi_env('HTTP_CAMS_HTTP_USER') and assign the value for use in processing. I am trying to do this in my on-logon trigger of the form.
    Forms run-time is giving me :
    numeric or value error ORA 06512 at SYS.OWA_UTIL, line 356 ORA-06512 at SYS.OWA_UTIL line 375..
    Is it possible to use this function in Forms 10g running the 10g OAS, which is supposed to be based upon APACHE?
    Thank you,
    Tony Miller
    Webster, TX

    The value that the SSO package we use stores. It is the user's user id. We also have the actual session id in the SSO application available. AT this time, when we fire up a forms session, we have an .shtml file that calls the form url with a parameter, the session ID (from a cgi variable available to the .shtml file). I am trying to access that cgi variable so we DON'T need a parameter being passed on the url line for our main Form into the application..
    Thank you,
    Tony Miller
    Webster, TX

  • Capture full URL with CF CGI variable

    I need to capture an entire URL and send it in the body of an
    email, using CFMAIL. I'm looking at my CGI variables using CFDUMP,
    but can't seem to get the entire URL string, including the
    http:// or https://. Help?

    That part of the URL is intended for the browser, and is not relevant to the server so is not transmitted with the request, so it never gets to the web server, let alone the CF server.
    If you need that info, you're gonna need to send it some other way.
    Adam

  • Flash & Coldfusion: retrieving variables from Coldfusion

    I'm interested in receiving variables from Coldfusion without
    reloading my swf.
    (In a way that doesn't make me load out of some random text
    file).
    Does anyone know how to do this?

    use the urlloader class to send data to and receive data from
    cf.

  • WebSEAL/CGI variable question

    Regarding WebSEAL. There are various http header variables
    created during an authentication of a user, including:
    HTTP_IV_USER. Is this variable available to CF as an cgi variable,
    or is it available as part of the cgi.cert_subject variable. And if
    so, what would sample content of this variable look like when it
    includes this custom information? Due to the red tape of getting
    into a sandbox to see what these variables look like, I was
    wondering if someone had any idea of the formatting involved and if
    this data really is passed from WebSEAL.

    I am aware of that function, thank you. The issue is really
    that I do not have access to the environment at this time. I wanted
    to get a sneak peak, so sould begin some initial coding. The red
    tape to get to the testing area is tremendous, so I want to have a
    solid idea of what the output of that variable would look
    like.

  • Error  while assigning resultset value to Querytable variable in Coldfusion 10

    We are upgrading from coldfusion 8 to 10. Internally we were using java function to to get the data.
    In java function we have a resultset object, if we assign this resultset value to Querytable variable, we are getting below error. This code was working fine in coldfusion 8.
    Detail    This exception is usually caused by service startup failure. Check your server configuration.
    Message    The Runtime service is not available.
    StackTrace    coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.runtime.RequestMonitor.<clinit>(RequestMonitor.java:14) at coldfusion.sql.QueryTable.populate(QueryTable.java:358) at coldfusion.sql.QueryTable.populate(QueryTable.java:283) at coldfusion.sql.QueryTable.<init>(QueryTable.java:96) at com.myCompany.myClass.myFunct(myClass.java:627) at
    Here is the function which is causing error.
    static private QueryTable myFunct(String userId, SessionFactory sf) {
            PreparedStatement pStmt = null;
            ResultSet rs = null;
            QueryTable ret = null;
             try{
                Query q = sf.getCurrentSession().getNamedQuery("ListUsers");
                pStmt = sf.getCurrentSession().connection().prepareStatement(q.getQueryString());
                rs = pStmt.executeQuery();// works fine till here
                ret = new QueryTable(rs);  // error line         
                rs.close();
            }catch(Exception e){
                e.printStackTrace();
                throw new RuntimeException(e.getLocalizedMessage());
            return ret;
    Can you provide some help on this. Please let me know if you need any other details.

    We have found this error is logs
    coldfusion.runtime.Encryptor$InvalidParamsForEncryptionException: An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same..
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:303)
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:284)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5353)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5326)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5458)
        at com.vmware.vcp.service.impl.EncryptColdFusionImpl.decrypt(EncryptColdFusionImpl.java:65)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.initEmailService(ApplicationConfigSer vlet.java:119)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.init(ApplicationConfigServlet.java:51 )
        at javax.servlet.GenericServlet.init(GenericServlet.java:160)
        at coldfusion.bootstrap.ClassloaderHelper.initServletClass(ClassloaderHelper.java:121)
        at coldfusion.bootstrap.BootstrapServlet.init(BootstrapServlet.java:59)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5001)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5278)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

  • Apache mod_rewrite with virtual sites

    Hello,
    I have a number of development websites located in /Users/myusername/Sites/* that I can browse to easily as http://myhostname/~myusername/siteOneName etc. Works fine.
    Some of the sites are images of production Joomla sites I maintain, and they work fine too.
    HOWEVER, I need to enable mod_rewrite to match the production. As it is, the URLs for pages in my local site are ugly data-search page numbers rather than the easy-viewing SEF addresses like "about-us" or "product-1" etc.
    In /etc/apache2/httpd.conf
    LoadModule rewrite_module is okay
    AllowOverride All is set in the .htaccess section
    .htaccess is present the the root of the Joomla site and contains "RewriteEngine On."
    In /etc/apache2/users/myusername.conf
    AllowOverride All is set
    I tried setting up a virtual site in apache2/other, but I didn't know what I was doing and it didn't work.
    There's something I'm missing here.
    Ideas?

    Discussions is intended for discussions of Apple products. The Apache server is not an Apple product like say Snow Leopard, but a project of the Apache Software Foundation. Documentation, FAQ's, & tutorials for its use are available through http://httpd.apache.org/, but the foundation provides no official support. Support is available from commercial sources, some of which are listed at http://www.apache.org/info/support.cgi.
    You also might want to post a detailed description of your issue in the UNIX forums here, but posting in the Installation and Setup sub-category of the Snow Leopard one is unlikely to get you the attention of many Apache experts.

  • Apache Mod_Rewrite in an Alias

    Hello,
    I have mod_rewrite working just fine for files that are in /srv/http. I copied my test files to another directory where I have an alias pointing and tried them there but was not able to get it working. Is anyone able to spot what I am doing wrong? Here are my configs:
    Relevant portions of httpd.conf
    Alias /tv "/home/username/a/folder/path"
    <Directory "/home/username/a/folder/path">
    Order allow,deny
    Options FollowSymLinks
    Allow from all
    AllowOverride All
    </Directory>
    Let me know if there are other files that would help.
    Edit:
    So I have been doing a bit more research. In the end I am trying to get codeigniter installed and running on my.ip.address/tv. I have found this page from code igniter on the topic which says that the mod_rewrite stuff can be done in the http.conf file. Scroll to the very bottom to see what I am talking about.
    http://codeigniter.com/wiki/mod_rewrite
    So going off of that, here is what I am trying to use. Please let me know which portion I need to change if you can spot any problems.
    Alias /tv "/home/username/a/folder/path"
    <Directory "/home/username/a/folder/path">
    Order allow,deny
    Options FollowSymLinks
    Allow from all
    AllowOverride All
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    </Directory>
    Last edited by Abadon125 (2012-02-11 07:50:45)

    OK, as part of my work-avoidance for the day, I have replicated the work I did in NZ on my other laptop.
    I put this in httpd.conf
    Alias /junk C:/webroots/junk
    <Directory "C:/webroots/junk">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        RewriteEngine  on
        RewriteBase    /junk/
        RewriteRule (.*) $1 [E=MYCUSTOMVARIABLE:mycustomvalue]
    </Directory>
    And my test code is this:
    <cfoutput>
    CGI.MYCUSTOMVARIABLE = [#CGI.MYCUSTOMVARIABLE#]<br />
    </cfoutput>
    I restart Apache, run the template, and I get this:
    CGI.MYCUSTOMVARIABLE = [mycustomvalue]
    How does this differ from what you're doing?
    Adam

  • Apache + mod_rewrite

    i've got a problem with mod_rewrite - it doesn't work.
    (~)$ cat /etc/httpd/conf/httpd.conf| grep mod_rewrite
    LoadModule rewrite_module modules/mod_rewrite.so
    (~)$ cat /home/httpd/html/.htaccess
    Options FollowSymLinks
    RewriteEngine On
    RewriteRule ^index.html$ index.php [L]
    http://localhost/index.php works fine but http://localhost/index.html gives 404 error
    could someone know, where the fsck is problem?
    btw sorry for my english if i made some mistakes. i'm from poland

    thanks. it was allowoverride's fault.
    and btw i've got another problem. apache don't parse php files when them are in different directory than "/home/httpd/html", e.g. if i set DocumentRoot (and <Directory "..."> too, of course) to "/mnt/data/htdocs". why?
    Last edited by dawidgarus (2007-12-30 16:40:18)

  • Apache mod_rewrite and mod_wl together

    Hi everybody,
    I'm having a problem with apache (1.3.27 on linux) mod_rewrite and mod_wl.
    The httpd.conf looks like this:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} Id=100
    RewriteRule ^/dynamic/tops$ /static/100.html [P]
    <Location /dynamic>
    SetHandler weblogic-handler
    </Location>
    Background:
    http://www.my.domain/dynamic/tops?Id=100 is requested very often, also the
    updates of this information is not very often.
    So a cronjob is requesting this information and writting the result as
    apache/htdocs/static/100.html.
    Because of the links inside the document, I can't link to it with the static
    path, I must use the dynamic path.
    The rule is working fine when I do a redirect (can't do that for other
    reasons)
    Proxying the request will work if I remove the weblogic-handler of the
    httpd.conf.
    But if I want to run it like that configuration above I see the page is
    created by the weblogic server and not the static one.
    Has anyone an idea what to do.
    Martin

    Hi everybody,
    I'm having a problem with apache (1.3.27 on linux) mod_rewrite and mod_wl.
    The httpd.conf looks like this:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} Id=100
    RewriteRule ^/dynamic/tops$ /static/100.html [P]
    <Location /dynamic>
    SetHandler weblogic-handler
    </Location>
    Background:
    http://www.my.domain/dynamic/tops?Id=100 is requested very often, also the
    updates of this information is not very often.
    So a cronjob is requesting this information and writting the result as
    apache/htdocs/static/100.html.
    Because of the links inside the document, I can't link to it with the static
    path, I must use the dynamic path.
    The rule is working fine when I do a redirect (can't do that for other
    reasons)
    Proxying the request will work if I remove the weblogic-handler of the
    httpd.conf.
    But if I want to run it like that configuration above I see the page is
    created by the weblogic server and not the static one.
    Has anyone an idea what to do.
    Martin

  • Apache won't start after ColdFusion Install

    Any suggestions on what to look for, as to why Apache will
    not start after installing ColdFusion MX Dev Edition on a Win 2003
    Server? Is there something in a log file I could look at? Any help
    is appreciated. Also, when I take the JRUN mod out of the Config
    file, Apache starts back up..
    Thanks,
    Brian

    If you're using Apache 2.2+ and CFMX 7+, then you need to
    apply
    a
    hotfix for CF.
    Once you update the wsconfig.jar file, re-run the Web Server
    Configuration Tool. Remove the old Apache mapping and create a new
    one.

  • Returning CGI variables thru java

    I am trying to check the cgi environment variables on my application server 10.1.2. I am unable to get any of the ssl variables at all. I can run /cgi-bin/printenv and see all the variables. However I am unable to get them out thru java. I dont know if I am missing something in the configuration of the server or not. I have it set up to run SSL and SSLVerifyClient so the clients have to provide a valid certificate. I need to grab the information off of that certificate to authorize their access. Any help would be much appreciated. Thanks!

    We did figure it out. We needed to make the following changes in our 10.1.3 environment. It should be similar in the 10.1.2 environment.
    ssl.conf or httpd.conf -
    Set the following setting in a context (either VirtualServer, Location,
    Directory, or File - others may work)
    SSLOptions +StdEnvVars
    mod_oc4j.conf -
    Add the following lines to if IfModule context
    Oc4jEnvVar SSL_CLIENT_S_DN
    Oc4jEnvVar SSL_CLIENT_S_DN_CN

  • Shell-Cgi on windows (Coldfusion and PERL)

    I'm running SJSWS 7.o on Win Server 2003. I have configured it to work with CFMX 7 as well as shell-cgi. I require both for new development and supporting legacy PERL programs.
    My problem is this. If I limit the shell-cgi to a single directory all works fine, but if I set the shell-cgi to the entire document root, the coldfusion files will not work. It should be possible to serve both file types from the same directories. Is there something I'm missing in the configuration or will I have to limit the the shell-cgi to a single directory.
    Again, any help would be appreciated

    That was what I originally tried to do to no avail.
    By creating a shellcgi directory and modifying the <vi-s-id>conf.conf file (i.e adding - NameTrans fn="pfx2dir" from="/cgi-bin", dir="<dirpath>" name="shellcgi", which the system did not add) the perl and cgi files worked within that directory, but CF files would not and if I modified the directory to the entire document root, PERL and CGI would work, but again CF would not.
    I removed the directory and made sure the cgi as file type was selected. CF worked but no cgi or perl.
    I checked the mime types and there was an entry for cgi and shellcgi, but both were referencing the same file types (cgi, exe, pl). I deleted the magnus-internal/cgi mime type and everything works as it should.
    Thanks for the help...
    null

  • Apache mod_rewrite, htaccess and virtual host

    Does not appear that the htaccess file is doing anything at all; I tested with a 301 redirect and even put some random nonsense in it in hopes to provoke a server error and nothing.
    httpd.conf : http://pastebin.com/36qFCg5q
    httpd-vhosts.conf
    <VirtualHost *:80>
        DocumentRoot "/Users/jwindhall/Railo/tomcat/webapps/ROOT/dentist_app"
        ServerName xxx.com
        ServerAlias www.xxx.com
    <Directory "/Users/jwindhall/Railo/tomcat/webapps/ROOT/dentist_app">
        Options All Includes Indexes
        Order allow,deny
        Allow from all
        AllowOverride All
    </Directory>
    ProxyRequests Off
    <Proxy *>
    Options All Includes Indexes
    Order allow,deny
    Allow from all
    AllowOverride All
    </Proxy>
    ProxyPass / http://www.xxx.com:8080/
    ProxyPassReverse / http://www.xxx.com:8080/
    </VirtualHost>
    jwindhall.conf:
    <Directory "/Users/jwindhall/Railo/tomcat/webapps/ROOT/dentist_app">
    Options Indexes MultiViews FollowSymlinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    The question etresoft was asking was around what goal or end or configuration you were trying to achieve here, and not who you might be.  With some background on the problem and on the particular goal, we might be able to provide you with a more direct solution, or debug the error. 
    It looks like you're trying to run some Tomcat stuff.  Something like this?
    Though that articile doesn't indicate it, the provided set-up there looks to be specific to OS X client.  Are you running OS X Server, or OS X client.  And in either case, which version?   (The management user interfaces do vary here, both by client and server, and by version.)
    The article also looks to be for 10.6 or earlier, or it presumes that you have Java installed.  That's not the default, so that's something you'll need to establish.
    Apache redirects do work on OS X and OS X Server.  If you're just testing that, get rid of Java and Tomcat and the rest (from your configuration test) and test just the URL redirects.
    Apache is also sensitive to file protections and ownerships, as it strives to avoid allowing an attacker at your whole system (by default), though those protections can be overridden.
    As a first step toward troubleshooting your current configuration, invoke the Apache configuration test on your system and see if it tosses any errors, and also check the Apache server logs for relevant errors.  The logs are usually in the /var/log/apache2 directory, though that can be changed.  This'll make sure the core giblets are working.  The next steps would usually then involve checking the protections on the web directories, and then testing Java and Tomcat individually.
    OS X Server is a little more simple to set up and (mostly) avoids needing to access the configuration files, and the directories and related are IMO a little easier to deal with; you're using Server Admin.app or Server.app (depending on the OS X Server version) to manage all that, and not a text editor.
    And you may already be aware of this; do not try to use a GUI editor to edit the configuration files.  TextWrangler will work here, but most other GUI editors won't.  Using a command-line editor is more common; nano or vim or emacs or such.  FWIW.

  • Still problems with Apache and cgi

    I thought it was the "admin" vs "staff", but that isn't the problem. I switched everything to staff but the scripts that weren't working still aren't.
    I've checked everything out that I can see (basically the ls -l listing) and I cannot see anything different between the two files.
    If I go into the one that works (newshdr.cgi) and paste into it the code from the cgi that doesn't work (newsshow.cgi) the code works. But, if I copy the code from the working cgi into the non-working cgi the latter still doesn't work. So, from this, I know it is not anything in the code itself -- it must have something to do with the files. But I'll be darned if I know what.
    Both cgi's are in the same directory, so the permissions down to there are the same. Both cgi's are -rwxrwxrwx, so that isn't the problem. Both now state "staff" instead of the non-working one being "admin".
    I am really stumped. Any help would be greatly appreciated...IOW HELP!!!!!
    Mike

    Not much help, this is the log:
    [Tue Sep 26 17:18:24 2006] [error] (2)No such file or directory: exec of /Users/mike/Websites/KTA-Hike.tst/cgi-bin/AlertShow.cgi failed
    [Tue Sep 26 17:18:24 2006] [error] [client 127.0.0.1] Premature end of script headers: /Users/mike/Websites/KTA-Hike.tst/cgi-bin/AlertShow.cgi
    But the file is there, here's the listing from Terminal:
    [Mike-Lipays-Computer:~] mike% cd /Users/mike/Websites/KTA-Hike.tst/cgi-bin/
    [Mike-Lipays-Computer:~/Websites/KTA-Hike.tst/cgi-bin] mike% ls
    AlertAdd.cgi NewsForm.cgi RegisterShow.cgi
    AlertForm.cgi NewsHdrs.cgi TrailRegister.cgi
    AlertMaint.cgi NewsLoad.cgi calendarscript
    AlertShow.cgi NewsMaint.cgi counter.cgi
    Contact.cgi NewsShow.cgi counter.txt
    Damage.cgi OrderForm.cgi xNewsHdrs.cgi
    EmailLoad.cgi RegisterLoad.cgi xNewsShow.cgi

Maybe you are looking for