...
Wiki Markup |
---|
This can be run periodically from Cron, after you upload content, etc. To make Apache substitute the statically rendered pages for the dynamic content, we’ll use mod_rewrite. This module is included with the Apache source code, but is not compiled by default. It can be built with the server by passing the option {{\-\-enable-rewrite\[=shared\]}} to the configure command. Many binary distributions of Apache come with mod_rewrite included. The following is an example of an Apache virtual host that takes advantage of pre-rendered blog pages: |
No Format |
---|
Listen *:8001
<VirtualHost *:8001>
ServerName blog.sandla.org:8001
ServerAdmin sander@temme.net
DocumentRoot "/home/sctemme/inst/blog/httpd/htdocs"
<Directory "/home/sctemme/inst/blog/httpd/htdocs">
Options +Indexes
Order allow,deny
Allow from all
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA]
</Directory>
RewriteLog /home/sctemme/inst/blog/httpd/logs/rewrite_log
RewriteLogLevel 9
ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
LogLevel debug
CustomLog /home/sctemme/inst/blog/httpd/logs/access_log common
ScriptAlias /cgi-bin/ /home/sctemme/inst/blog/bin/
<Directory "/home/sctemme/inst/blog/bin">
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
|
The RewriteCond
and RewriteRule
directives say that, if the requested resource does not exist as a file or a directory, its path is passed to the Blosxom CGI for rendering. Blosxom uses Path Info to specify blog entries and index pages, so this means that if a particular path under Blosxom exists as a static file in the file system, the file is served instead. Any request that isn't pre-
rendered is served by the CGI. This means that individual entries, which show the comments, are always served by the CGI which in turn means that your comment spam is always visible. This configuration also hides the Blosxom CGI from the user-visible URL in their Location bar. mod_rewrite is a fantastically powerful and versatile module: investigate it to arrive at a configuration that is best for your situation.
...