1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Make apache serve image files with a cgi script

Discussion in 'Apache' started by davedx, Sep 13, 2007.

  1. #1
    I'm trying to get apache to serve image files (e.g. .gifs) via a cgi script, ideally a php script.

    At the moment I've managed to get it to execute a batch file whenever an image is requested, and I can access the requested path using the PATH_INFO environment variable. The problem is I want to use a php script instead, and I can't seem to get the script to run when it's called (via the batch file) by apache.

    My httpd.conf has:

    
    	ScriptAlias /imgs/ "C:/xampplite/imgs/"
    	AddType application/x-httpd-gif .gif
    	Action application/x-httpd-gif "/imgs/proxy.bat"
    
    	<Directory "C:/xampplite/imgs">
    		AllowOverride AuthConfig
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    Code (markup):
    The batch file:

    
    @c:/xampplite/php/php.exe c:/xampplite/imgs/proxy.php %PATH_INFO% > 1.txt
    
    Code (markup):
    The PHP script runs ok if I run proxy.bat from the command line (it just echos its command line arg), and 1.txt contains the output. When it's called by apache, there's no output :(

    Any ideas on how to get this working? A more elegant solution that doesn't involve batch files would be nice too :)

    Thanks
     
    davedx, Sep 13, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tryed using AddHandler at all ?

    you might be able to use that to force images to go via another mechimism (excuse spelling)
     
    powerspike, Sep 13, 2007 IP
  3. davedx

    davedx Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, tried AddHandler too.

    Ended up using mod_rewrite in the end, nice simple regexp instead of a nasty hack in the config works out better in the end :)
     
    davedx, Sep 17, 2007 IP