Htaccess | Dragonfly web framework

Apache's .htaccess file

Because Dragonfly runs under the CGI protocol, it needs the server to redirect URL requests to it so that your website's URLs look like this:

http://www.rundragonfly.com/welcome

Instead of this:

http://www.rundragonfly.com/?welcome

The .htaccess file included with Dragonfly is set to rewrite the requested URL and pass it to Dragonfly's index.cgi file which in turn triggers Dragonfly's own routing mechanism.

Why It's Important

We only want some of the requests to be passed to Dragonfly for processing. It wouldn't make sense, for example, for Dragonfly to handle a request for an image file:

/includes/images/dragonfly_logo_white.gif

By default, the .htaccess file is setup so that two kinds of requests are redirected to Dragonfly for routing:

  1. "Non-existent" files
  2. Files matching a certain extension

As an example of "non-existent" files, take look at the URL for this page. There is no "htaccess" file in the root of this website, and therefore the request is sent to Dragonfly which transforms it so that we're served the actual file, located here:

/views/htaccess.html

Which brings us to the second type of request that is redirected to Dragonfly: requests matching certain file extensions. This allows requests for actual files to be routed through Dragonfly.

By default, the .htaccess file is set to forward all requests for files ending in ".html" or ".nl" to Dragonfly. Because of this, you can go ahead and safely visit this page directly, the newLISP code inside of it will still be processed.

Modifying the .htaccess file

Apache configuration files, regular expressions, and mod_rewrite are beyond the scope of this tutorial, however, we'll leave you with a quick example that shows how to make it so that files ending in ".foo" are also passed through Dragonfly.

Edit the .htaccess file and change this line:

RewriteCond %{REQUEST_FILENAME} \.(html|nl)$

To:

RewriteCond %{REQUEST_FILENAME} \.(html|nl|foo)$

CONTINUE »

Rendered in 1 milliseconds. Used 83 KB of memory, 58 KB for Lisp Cells.