Calling a revServer script from inside a .html page?

Richard Gaskin ambassador at fourthworld.com
Sat Dec 18 09:59:14 EST 2010


Keith Clarke wrote:

 > Pierre, Thanks for the clarification. Not quite the answer I was
 > hoping as I want to rev-enable existing auto-generated pages where
 > I can't change the page mime-type from html.

That's how just how Apache works with RevServer and AFAIK any other 
CGI-like process that you want the server to invoke for further processing.

With mod-rewrite rules in a .htaccess file you can do all sorts of stuff.

RevServer installs require this anyway; it's included by default with 
on-rev.com accounts, and to use RevServer on any other server you need 
to put those rules into a .htaccess file; without them, Apache would 
have no way to know to hand off those page requests to your CGI.

Here's the one I use at livecodejournal.com:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+)\.irv$  /cgi-bin/irv.cgi?%{REQUEST_FILENAME} [L,NC,QSA]

In brief, it says to take any request for a file ending in .irv and hand 
it over to /cgi-bin/irv.cgi for further processing before passing the 
results back to the requester.

mod_rewrite is very powerful, and well worth the modest amount of time 
needed to become familiar with it.   Like most Apache modules, it's well 
documented all over the web.  The Apache docs are a good start:
<http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html>

...and there's a ton of other great examples and tutorials to be found.

One challenge with using .html is that you may want to have some static 
pages there, and just replacing ".irv" with ".html" in the rules above 
will redirect all .html requests to your CGI, which can eat more 
processing time than necessary if you leave it up to your CGI to 
determine whether to do further processing or just hand the contents 
back to Apache.

That's why most configs specify certain file types for specific 
additional processing (e.g., ".php" for PHP, ".asp" for Microsoft's DB 
setup, ".irev" for RevServer, etc.).

But if you really want your CGI to process all .html requests, you can 
modify the rules above and drop it in a .htaccess file on your server 
and you're good to go.

One useful thing to keep in mind is that any mod_rewrite rules in a 
.htaccess file affect only the directory that the .htaccess file is in 
and any subdirectories within it.  So if you wanted to have one folder 
that gets preprocessed with a CGI while using other folders for static 
pages, just put your .htaccess file in the folder where you want the 
pages processed and the others will be left for Apache to handle by itself.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv




More information about the Use-livecode mailing list