Lets say I have a file with a .quote extension. I’d like the web server to send the contents of this file through a simple PHP script before sending it to the browser.
For example:
This is a quote
Would be transformed to
“This is a quote”
It looks as though I need to put something in my .htaccess along the lines of
AddHandler x-quote .quote
Action x-quote /cgi/quote.cgi
And then my script would be something like
#!usr/local/php5
<?php
header("Content-type: text/plain");
#I don't know how to do this step...
echo '"'.$CONTENTS_OF_THE_FILE.'"';
?>
However, now I just get an error 404 when I look at the .quote file on the server.
I can think of a few things that might be causing this:
- The cgi file is not being found and/or executed – How can I determine if cgi files are allowed to run on my server? Should the path be relative to the webroot?
- The path to the php executable is incorrect – Is this listed somewhere in php.ini? If so, where?
- I’m not doing the right thing in the PHP itself – What should I be doing
I do not have SSH access to the server in question.
Why not just run it through a normal PHP file rather than CGI and use mod_rewrite?
Your .htaccess would look like
Your PHP: