Execute a script each time a page is requested

Posted on 2004-11-28
Last Modified: 2010-03-04
Is there a way to have a CGI script execute each time a page is requested on my web site? The CGI script doesn't have output - it is more of a maintenance script. I don't want to use SSI. I also don't have access to the main server configuration file. Is there a way to do this with perhaps .htaccess?

Thank you,
Question by:ericl1st
    LVL 51

    Accepted Solution

    write your CGI so that it reads the requested page and prints it on STDOUT, then add to .htaccess

    RewriteCond %{REQUEST_URI}  ! ^/cgi-bin/your.cgi$
    RewriteRule ^.*$    /cgi-bin/your.cgi

    # keep in mind that your server needs to allow rewriting from within .htaccess
    LVL 1

    Author Comment


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting ( to http…
    In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now