Is it possible create a trigger on apache ?

Discussion in 'Apache' started by jmauver, Oct 18, 2009.

  1. #1
    Hello community,

    I have a web site hosted by third party company which offers me cpanel to control my site. I have several jpg/bmp files hosted there which my users do a hot link and display the images in their sites. I was wondering if would be possible to run a php script when apaches receives a request to serve a image. It would be like a trigger everytime a image request is sent to my server. Any ideia in how I can acomplish this will be much appreciated. Thank you very much.

    Rgds

    Mauver
     
    jmauver, Oct 18, 2009 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    You can use mod_rewrite to have requests for images go to your script behind the scenes, then have the script work with "$_SERVER['REQUEST_URI'] which should refer to the image requested to send the headers for the image and read the image out to the browser.
     
    joebert, Oct 19, 2009 IP
  3. jmauver

    jmauver Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you Joebert ! Just one quick question, do I need to configure Apache for mod_rewrite ? I mean, is it something that only the server administrators can do or I can do it myself by using cpanel/php scripts ? Sorry for if the answer is so obvious, I am really a newbye on this :eek:

    Kind regards,

    Mauver
     
    jmauver, Oct 19, 2009 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    If Apache is installed, chances are mod_rewrite will be there too. I don't think I've ever seen a modern Apache-based host that doesn't have mod_rewrite available.

    If it's not there though, an Administrator is the only one who can install it.
     
    joebert, Oct 20, 2009 IP