Attention! Helicon Tech Blog has moved to

Tuesday, July 6, 2010

mod_seo — next level of SEO-friendliness

No so long ago we've introduced mod_seo module for Helicon Ape and now want to represent it to everyone.

What is it about? — mod_seo offers a new handy way of optimizing your site for search engines.
To cut this story short we’ll show a real-life example — how we applied mod_seo on our forum.

What we need: Helicon Ape, Microsoft SQL Server, forum database.
What we do:
  1. Enable mod_dbd and mod_seo modules in httpd.conf
  2. And use the following lines in .htaccess in the root of our site:

    # Declare  a database driver for the forum database
    DBDriver mssql
    # Include DBDParams string for correct SQL connection.
    DBDParams "Data Source=(local)\SQLDB;Initial Catalog=WebWizForum;User ID=sa;Password=***"
    # Prepare SQL queries to select topic subject by Topic_ID 
    # (taken from request URL) 
    DBDPrepareSQL "SELECT [Subject]     FROM [WebWizForum].[dbo].[tblTopic] 
                   WHERE [Topic_ID] =@KEY" getSeoTopic
    # and forum name by Forum_ID (also taken from request URL)
    # from the corresponding db tables
    DBDPrepareSQL "SELECT [Forum_name]  FROM [WebWizForum].[dbo].[tblForum] 
                   WHERE [Forum_ID] =@KEY" getSeoForum
    # Declare rewrite maps that refer to the prepared sql queries
    RewriteMap SeoTopic   dbd:getSeoTopic
    RewriteMap SeoForum   dbd:getSeoForum
    RewriteMap slug int:slug
    # Replace matched pattern in "a href" tags with substitution 
    # including the forum name taken from the db-driven map based on Forum_ID
    SeoRule forum_topics.asp\?FID=(\d+)$ 
          forum$1-${slug:${SeoForum:$1|not-found}}.html   [Redirect,Scope=A]
    # the same but accounting for page number parameter (PN)
    SeoRule forum_topics.asp\?FID=(\d+)&PN=(\d+)$ 
          forum$1-${slug:${SeoForum:$1|not-found}}-$2.html   [Redirect,Scope=A]
    # Replace matched pattern in "a href" tags with substitution 
    # including the topic name taken from the db-driven map based on Topic_ID
    SeoRule forum_posts.asp\?TID=(\d+)(?:&PN=(\d+)&TPN=(\d+))?(?:&(get=last))?$ 
          $1-${slug:${SeoTopic:$1|not-found}}(?2-$3).html?4\?$4 [Redirect,Scope=A]
  3. Enjoy URLs like
    instead of
    (You may check them both as they are live.)
Note: SeoRule directive has a meaning very close to that of RewriteRule, the only difference being that it replaces links on pages according to the Substitution pattern (not rewrites requested URLs).

If you want something of that kind on your site, don’t hesitate to try mod_seo on your site (remember, Helicon Ape is totally free for up to 3 sites!).

Best regards,
Anton — HeliconTech Team

Wednesday, May 12, 2010

Automatic cache cleaning in Helicon Ape

Up to version Helicon Ape cache could be cleaned only manually. Memory-based cache (mod_mem_cache) required recycling of corresponding application and disk-based cache (mod_disk_cache) cleaning implied manual files deletion form the file system. That was slightly inconvenient, to put it mildly.
Helicon Ape (and newer) got support of cache cleaning upon request.
Now, to clean cache just set the cache-clear environment variable. This will cause cache cleaning corresponding to the current request (context).

Setting cache-clear variable using SetEnvIf directive provides flexibility of conditions that will lead to cache cleaning.

For example, to trigger cache cleaning by requesting specific URL:
SetEnvIf request_uri ^/system/cache/clear/$ cache-clear=1
To trigger cache cleaning by appending specific query string value:
SetEnvIf Query_String clear_cache_request cache-clear=1
For security purposes it may be necessary to clean cache only from definite IP address:
SetEnvIf (Query_String clear_cache_request) and (Remote_Addr 11\.22\.33\.44) cache-clear=1
Cache cleaning may take some time, so be ready.

When cache cleaning is over, the error.log (with info or higher verbosity level) will display the number of deleted records.

Best regards,
Ruslan, Anton - Helicon Tech Team

Thursday, April 22, 2010

Titbits: Making Ape work with Plesk 9.5.1

If you have Ape and Plesk installed on your server, you may come across the issue that Ape is not working it it's entirity. This may be caused by the fact that Plesk overrides the handlers list for each domain it creates. Like this:
<location path="">
            <handlers accessPolicy="Read, Script">
                <clear />
                <add name="Plesk_Handler_05171048" path="*.dll" verb="*" 
                    modules="IsapiModule" resourceType="File" 
                    requireAccess="Execute" allowPathInfo="true" />
                <add name="Plesk_Handler_05171080" path="*.exe" verb="*" 
                    modules="CgiModule" resourceType="File" 
                    requireAccess="Execute" allowPathInfo="true" />
                <add name="StaticFile" path="*" verb="*"
                    DirectoryListingModule" resourceType="Either" />
To add handler for Helicon Ape, you need to add this simple spell to the root web.config for the site:
<?xml version="1.0" encoding="UTF-8"?>
      <add name="Helicon.Ape Handler" path="*.apehandler" verb="*" 
          type="Helicon.Ape.Handler" resourceType="Unspecified" 
          preCondition="integratedMode" />


Guess, this small hint will make Plesk and Ape cohabitation on your server more peaceful.

Best regards,
Sergey, Anton - Helicon Tech Team

Wednesday, March 31, 2010

Titbits: Disabled ASP.NET handler prevents Ape from working

There have always been problems with any kind of software, when the software itself is installed correctly but doesn’t seem to work.

The same problem occured with Helicon Ape while installing on Windows Server 2003, IIS6. User had full control of config files and was able to browse the sites in IIS, but not a single rule took effect.

Investigation of the problem led us to IIS Manager/Web Service Extensions. The ASP.NET handler was disabled, which was completely blocking Helicon Ape operation.

The reason is that Ape is an ASP.NET module which can’t be run with appropriate handler “prohibited”.

One look is all it takes to find a solution to the issue – press “Allow” button for ASP.NET in Web Service Extensions:

Best regards,
Andrew & Anton, Helicon Tech Team

Thursday, March 18, 2010

ISAPI_Rewrite3 vs LinkFreeze - which is better?

From time to time we get the questions of this kind on our forum/email, so I guess it's time to show the difference to everyone.
  1. Ease of use
    LinkFreeze is the unquestionable leader by this parameter. One dialog is everything you'll deal with - all settings are set up there.

    ISAPI_Rewrite in its turn is far more complex tool - you need to be aware of (at least) the basics of regular expressions to manage it. Most of the configuration is stored in plain text files which may be edited in a special manager.

  2. Functionality
    In this characteristic the situation is quite the contrary - ISAPI_Rewrite has incomparably more features than LinkFreeze, notably:
    - rewriting URLs in any way you want (e.g. having refer to;
    - proxying (e.g. having refer to;
    - mapfiles support (e.g. having refer to;
    - filtering requests based on server variables' values, IP addresses/domain names, referers, etc.

    LinkFreeze is achieving SEO-friendliness in a different way - it allows to make query string a part of the URL, move and change file extension (e.g. having refer to but the wording of the URL remains intact (addition/replacement/deletion of URL portions is not possible).

  3. SEO efficiency
    While LinkFreeze will automatically make your links on pages look like, with ISAPI_Rewrite3 you need to either alter them manually to look like or use 301 redirects (this may slightly decrease the pagerank of the page) to SEO-friendly page names and reverse internal rewriting to the actual page name. Here's how it looks like in terms of ISAPI_Rewrite 3 syntax:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{QUERY_STRING} ^param_id=(\d+)$ 
    RewriteRule ^real_page\.aspx$ seo_page-%1.html? [NC,R=301,L] 
    RewriteRule ^seo_page-(\d+)$ real_page.aspx?param_id=$1 [NC,L]
    So, the key difference is that LinkFreeze changes links on pages and ISAPI_Rewrite doesn't!

  4. Windows versions supported
    LinkFreeze supports Windows NT 4 (IIS 4), Windows 2000 (IIS 5), Windows XP (IIS 5.1) and Windows 2003 (IIS 6).

    ISAPI_Rewrite3 supports Windows 2000 (IIS 5), Windows XP (IIS 5.1), Windows 2003 (IIS 6), Windows Vista (IIS 7), Windows 2008 (IIS 7), Windows 7 (IIS 7.5) and Windows 2008 R2 (IIS 7.5).

    If you are the lucky user of IIS7 (7.5) and need ISAPI_Rewrite/LinkFreeze capabilities, you can benefit from using Helicon Ape tool which includes mod_rewrite and mod_linkfreeze as well as a bunch of other helpful modules and functions.
Hope this article favored better understanding of the products capabilities and peculiarities, and you choice will be more conscious.

Best regards,
Anton, Helicon Tech

Wednesday, March 10, 2010

Titbits: Plus sign in IIS7

This seems to be a known issue, but I'll cover it once again just in case...

So, after fresh install of IIS7 you are likely to notice that requests containing plus ('+') character are not accepted.
The issue is that by default IIS is set to not accept double escape sequences. Let's fix it.

Open IIS Manager, go to Request Filtering page and open Edit feature settings... dialog.
Now check the Allow double escaping option and press OK.
Note! The same can be set directly in web.config using the following code:
<?xml version="1.0" encoding="UTF-8"?>
            <requestFiltering allowDoubleEscaping="true" />
That done, refresh the page in the browser and you'll have it handled correctly.
Hope you'll find this tip helpful.

Best regards,
Anton, Helicon Tech Team

Thursday, February 25, 2010

Two-digit back-references in ISAPI_Rewrite and Ape

We've planned to implement it for a long time and eventually it's done.

In ISAPI_Rewrite and Ape one can have more than 9 submatches and consequently more than 9 back-references in both RewriteCond and RewriteRule (RewriteProxy, RewriteHeader) statements.

The syntax to address these submatches is illustrated in the following example:
RewriteBase /
RewriteCond %{QUERY_STRING} ^id1=(\d+)&id2=(\d+)&...&id10=(\d+)&id11=(\d+)$
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)...
    %1/%2/%3/%4/%5/%6/%7/%8/%9/%%10/%%11?id1=$1&id2=$2&...&id10=$$10&id11=$$11 [L]
Note! This syntax is not supported in Apache.

Note! We highly recommend to avoid rules like that (as they indicate your URLs are not really SEO-friendly), but if there's no other way out, do use it.

We believe this small bit of functionality will save you time and efforts.

Best regards,
Anton, Helicon Tech Team

Tuesday, February 23, 2010

"Zip and save" option in Ape Manager

Hello, everyone!

We want to inform you of a new helpful feature that is available in Helicon Ape and higher.

To make your interaction with our support team more fruitful we've introduced a context menu item "Zip and Save Ape Configuration" that makes an archive including all Ape config files for current location (on which you right-clicked) and its parents, web.config and Ape rewrite and error logs.

Having chosen the option you'll be informed about the files to be included into the package.

Note! All the files taken have proven to be essential for quick/efficient problem solving in most cases.

Notice that you can append additional files to the zip package later.

Finally, you'll be prompted to specify the location for the package to be saved (by default it's Ape installation folder). Our support team will be really grateful to get it for investigation.

We do hope this feature will help our support team resolve your issues within the shorter term.

Best regards,
Anton, Helicon Tech Team

Monday, February 22, 2010

New Helicon Ape released

Hello, everyone.

Good news - we've just released the new build of Helicon Ape -
So, what's new:
  • from now on you can write mod_proxy directives inside .htaccess files (previously only global context was supported);
  • "Zip and save Ape configuration" option in Ape Manager automatically saves and zips all Ape configs and logs for selected location (site, folder) so you could then send them to our support team;
  • bug fix related to processing of long URLs.
Best wishes,
Anton, Helicon Tech Team

Thursday, February 18, 2010

Titbits: Adjusting Coldfusion/ISAPI_Rewrite collaboration

If you have ISAPI_Rewrite3 (Ape) and Coldfusion installed on your server, you may encounter issues with requests to .cfm resources. The problem lies in handler mappings configuration. To resolve it, any handler mappings for *.cfm extension should be mapped to 1\jrun_iis6_wildcard.dll executable (instead of run_iis6.dll).

The following piece of code should be put into the web.config in the root of your site if you are on Windows Server 2008:

<?xml version="1.0" encoding="UTF-8"?>
    <remove name="AboMapperCustom-82624719" />
    <remove name="AboMapperCustom-82624718" />
    <remove name="AboMapperCustom-82624716" />
    <remove name="AboMapperCustom-82624717" />
    <remove name="AboMapperCustom-82624715" />
    <add name="AboMapperCustom-82624715" path="*.cfm" verb="*" modules="IsapiModule"      scriptProcessor="C:\ColdFusion8\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"
     resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
    <add name="AboMapperCustom-82624717" path="*.cfc" verb="*" modules="IsapiModule"
     resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
    <add name="AboMapperCustom-82624716" path="*.cfml" verb="*" modules="IsapiModule"
     resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
    <add name="AboMapperCustom-82624718" path="*.cfr" verb="*" modules="IsapiModule"
     resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
    <add name="AboMapperCustom-82624719" path="*.cfswf" verb="*" modules="IsapiModule"
     resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />

Anton, Helicon Tech Team

Friday, January 22, 2010

mod_dbd: Saying technically

Two previous articles—“Introduction to database functionality of Helicon Ape” and “How to connect mod_dbd with various databases” were aimed at every customer and they are enough if you don’t want to deepen into this matter. But in case you’re such a guy who wants to learn the internals of mod_dbd—please feel comfortable. In this article you’ll find what you need.
One little note: the text below requires basic knowledge of .NET Framework.

What’s inside

As you may guess mod_dbd completely relies on ADO.NET. This is a most common way for .NET applications. For more information on ADO.NET please follow the references below:
In other words mod_dbd loads any database provider through ADO.NET. Here is a scheme which illustrates the idea:

Database providers for Microsoft SQL Server and Oracle as well as ODBC and OLEDB interfaces were included in .NET Framework, so we support them natively and you don’t need to install additional software. However any other ADO.NET compatible provider may be used because mod_dbd is able to load external .NET assemblies. We’ll talk about that a little later. Now let’s take a look on connection pooling.

Connection pooling

mod_dbd in Apache supports connection pooling for threaded platforms. It has its own implementation with the help of APR library. We have considered to implement something similar but in a different way. ADO.NET kindly provides developers with connection pooling features, so mod_dbd uses nothing more. As opposed to Apache guys we have the fixed platform—Windows, so that’s pretty natural to use ADO.NET internal features.
Below we presume that you’re familiar with the connection pooling idea. If you’re not, please read the following great article by Dino Esposito: “The Connections of ADO.NET Connection Pooling”.

In ADO.NET connection pooling works very transparently. It’s configured through special connection string arguments. The following idea lays in the basis—connections with equal connection strings are put into one connection pool unless this breaks the connection pool rules.

So generally mod_dbd directs its directives values to particular connection string arguments. They are as follows:
  • DBDPersist → Pooling
  • DBDExptime → Connection Lifetime
  • DBDMax → Max Pool Size
  • DBDMin → Min Pool Size

Loading external providers

As we've mentioned before, mod_dbd is capable of loading ADO.NET providers from external .NET assemblies. Let’s consider one example which is probably better than dumb bare strings.
We’re going to use PostgreSQL connector. After downloading and extracting you will see Npgsql.dll assembly within bin folder. This assembly should be copied into GAC (C:\windows\assembly) or put near Helicon.Ape.dll. We’ve copied ours to GAC and opened the assembly’s properties:

The properties highlighted in red should be specified in DBDriver directive as follows:
DBDriver adonet "Npgsql.NpgsqlConnection, Npgsql, 
  Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
We also have to specify a connection string, so here is the final configuration:
DBDriver adonet "Npgsql.NpgsqlConnection, Npgsql, 
  Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" 
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=user;Password=password"
Quite easy, isn’t it? You are probably wondering whether this hinders the performance. Well, assembly loading isn’t a quick process, however mod_dbd does it only when configuration file changes. Usually it’s rare operation and you shouldn't worry about performance slump.


We’ve explained the internal organization of mod_dbd, described connection pooling implementation and provided you with an example of loading external database provider. This knowledge should help you in setting up your web-applications along with Helicon Ape in a very
efficient way.

Yours sincerely,
Helicon Tech team.

How to connect mod_dbd with various databases

This article is briefly describing the basic steps you should follow to configure mod_dbd and make it “understand” different databases.
The article mostly goes by those who don't want to know mod_dbd deeply but only have a desire to get Ape database modules working. More specific information you may find in “Introduction to database functionality of Helicon Ape” and “mod_dbd: Saying technically”.

Where and how to write mod_dbd configuration

The module directives are almost compatible with Apache mod_dbd but we've extended their scope and, as opposed to Apache, you may write mod_dbd directives in any configuration context: within <Directory>, <Location> and <VirtualHost> statements, in .htaccess and httpd.conf files.

Only two directives are required—DBDriver and DBDParams. Both are essential for creating a database connection and you will just have an error if mod_dbd can't retrieve one of these directives values. By the way, error.log is very useful in such cases. It may give you a hint why something isn't working.

The other mod_dbd directives may be omitted and then the default values are applied. We've taken them from original mod_dbd:
DBDPersist on
DBDExptime 300
DBDMax 10
DBDMin 1
Technical details of these directives are provided in “mod_dbd: Saying technically” article.

Note regarding DBDParams. mod_dbd doesn't parse directive's parameter but simply passes it to a database driver. It means that the directive doesn't have any special syntax for connection strings, instead you should use database-specific connection string arguments.

Also please don't use the following connection pooling arguments: Pooling, Connection Lifetime, Max Pool Size and Min Pool Size. They are automatically supplied by mod_dbd through its directives.

Here is a web-site which might be very helpful in connection string design:

Microsoft SQL Server

mod_dbd natively supports SQL Server version 7.0 or higher. It's not required to install any additional database providers, so the piece of code as follows would be enough:
DBDriver mssql
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=database;Password=password"
You may use the same connection string as in your web-site engine. Please refer to Microsoft SQL Server documentation for more details.


Oracle database is natively supported. No additional software required. The following example illustrates a general way to connect to Oracle database:
DBDriver oracle
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=database;Password=password"
Note! mod_dbd basically uses Microsoft drivers for Oracle, however it's possible to use Oracle drivers. Please find more information in the “Others” section below.


There is no native support for MySQL in Helicon Ape. However it's very easy to get mod_dbd working with this database. The best way is to install MySQL Connector for .NET. After installation please open C:\Windows\assembly folder and find MySql.Data assembly. You should open its properties dialog to get a few important values:

These values should be passed into DBDriver directive as a second argument with the following syntax:
DBDriver mysql "MySql.Data, Version=, 
  Culture=neutral, PublicKeyToken=c5687fc88969c44d"
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=database;Password=password"
This is how to make mod_dbd know about MySql.Data assembly. It provides interface to MySQL database through ADO.NET technology.
Although on a shared hosting you may copy MySql.Data.dll into the same location as Helicon.Ape.dll, then your configuration would be just like this:
DBDriver mysql
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=database;Password=password"
In spite of the fact that the method above is much better, you have another option. It also requires additional software—MySQL ODBC connector. ODBC works much slower and we don't recommend this approach, however if you prefer it—here is an example:
DBDriver odbc
DBDParams "Driver={MySQL ODBC 5.1 Driver};Server=server;Database=database;
Please pay attention to the mandatory argument Driver. Your version may be different.


We have considered only three database systems, however this isn't a limit for mod_dbd. It's capable of working with almost every database which supports ADO.NET, ODBC or OLEDB interface. And here is some explanation:


This way requires a bit of software development knowledge! If you have ADO.NET connector for one database system, knowing a full name of a connection class it provides you may load the connector as follows:
DBDriver adonet "System.Data.SqlClient.SqlConnection, System.Data,
  Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
The code above loads Microsoft SQL Server connector.


For this approach you need to install ODBC provider and know its name. The following example demonstrates connection to MySQL through ODBC:
DBDriver odbc
DBDParams "Driver={MySQL ODBC 5.1 Driver};Server=server;Database=database;


Like in case with ODBC you should have OLEDB provider installed. The following example demonstrates connection to Microsoft SQL Server through OLEDB:
DBDriver oledb
DBDParams "Provider=SQLOLEDB;Data Source=server;
  User ID=user;Initial Catalog=password"


We've described different approaches to connection mod_dbd with various database systems. Please notice that internal behavior and connection string format are very dependant on a particular database driver. However such feature as connection pooling works in any case because it's a natural capability of mod_dbd.

Yours sincerely,
Helicon Tech team.

Introduction to database functionality of Helicon Ape

New release of Helicon Ape has come out right after winter holidays. We wanted to fix a few found bugs and satisfy users' feature requests. However we also had a desire to bring something new and useful. So here you go—Helicon Ape v3.0.0.30 obtained database functionality. This means Ape has a potential to work with almost any RDBMS. Let’s
provide you with a little explanation. Please note, this article isn’t aimed to give you deep technical information or instruction steps. If you want these please consider “mod_dbd: Saying technically” and “How to connect mod_dbd with various databases”.


As well as Apache, Ape uses mod_dbd module as an interface to databases. The module organizes interaction between Ape and database drivers through which Ape modules may operate.
Though such database-driven modules are going to be your tools for doing some magic stuff on your server, you should configure mod_dbd to specify database driver, connection options and setup connection pooling. “How to connect mod_dbd with various databases” article will help you in this. Here are the basic features of mod_dbd:
  • Compatibility with original Apache mod_dbd module;
  • Configurable connection pooling which allows organizing connections in a very efficient way;
  • Native support for Microsoft SQL Server and Oracle;
  • ODBC and OLEDB interfaces support;
  • Possibility to load any ADO.NET compatible connector.
The following sections describe the modules we have already bound with mod_dbd.


This module is basically the same as mod_authn_file. The only difference as you may guess is that mod_authn_dbd retrieves credentials from a database. To make it working you should specify an SQL query because we don’t know your database structure and it’s not supposed to be limited to mod_authn_dbd needs.
The configuration below demonstrates mod_authn_dbd in action:
DBDriver mssql
DBDParams "Data Source=db_server;Initial Catalog=users_db;
  Persist Security Info=True;User ID=sa;Password=your_password"

# core authentication and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName "My Server"
AuthBasicProvider dbd

# core authorization configuration
Require valid-user

# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery "SELECT password FROM users_table 
As you may notice the code starts with two mod_dbd directives—DBDriver and DBDParams. Both are required for mod_dbd to work correctly, whereas others may be omitted.
These mod_dbd directives are needed to specify desired database driver and connection string. In the example above we’re connecting to Microsoft SQL Server. AuthBasicProvider dbd points to database-based authentication and finally SQL query is set through a special mod_authn_dbd directive AuthDBDUserPWQuery.

Map-files in mod_rewrite

This is probably one of the most exciting features. Before you would tell your web-site engine to regenerate a map-file according to database content. Now you have a possibility to appeal to the database directly and this is very easy to do:
DBDriver mssql
DBDParams "Data Source=server;Initial Catalog=database;
  User ID=user;Password=password"
DBDPrepareSQL "select OriginalURL from seo_mapping 
  where `SEO_URL`=@KEY" seo_map_select

RewriteEngine On
RewriteMap map_dbd dbd:seo_map_select
RewriteCond ${map_dbd:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND 
RewriteRule (.+) %1 [L]
As opposed to mod_authn_dbd, mod_rewrite doesn’t introduce any special directive for SQL query setup. Instead it uses DBDPrepareSQL which belongs to mod_dbd. DBDPrepareSQL links the query with the unique name and you should use this name in RewriteMap declaration. The rest of the rules should be familiar to you if you worked with map-files before.


We have considered a brand new feature of Ape—database connectivity. Along with core database module—mod_dbd—we've also touched upon mod_authn_dbd and mod_rewrite. Frankly saying this is not a limit and hopefully Ape will have loads of others database-oriented features. We’ll be accumulating customers' requests and will try and implement the desired functionality. Thanks for your cooperation.

Yours sincerely,
Helicon Tech team.

Titbits: dynamic mapfiles names

Not so long ago one of our clients urged us to test an interesting situation we've never tried before. The result was positive and saved him a lot of lines in the config file. Now we want to share this experience with you.

So, the conditions were:
  • about 300 mapfiles with the first part of name being the name of the city, e.g. london-map.txt, paris-map.txt, moscow-map.txt etc.;
  • the requests are made to the subdomains having the names of the cities, e.g.,, etc.;
  • requests to SEO-friendly URLs should be rewritten to the .asp page with the "id" taken from the corresponding mapfile and the "city" parameter being the city name.
To accomplish the above task with the least effort, we need the following.


london_seo_value1 11
london_seo_value2 22
london_seo_value3 33

paris_seo_value1 44
paris_seo_value2 55
paris_seo_value3 66

moscow_seo_value1 77
moscow_seo_value2 88
moscow_seo_value3 99

RewriteBase /

RewriteMap london-map txt:london-map.txt [NC]
RewriteMap paris-map paris-map.txt [NC]
RewriteMap moscow-map moscow-map.txt [NC]

RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${%1-map:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^([^/]+)/?$ city.asp?city=%1&id=${%1-map:$1} [NC,L]

The idea is that the first part of mapfile name is dynamic and depends on the name of the subdomain being requested.

Now upon request to you'll be shown the content of And upon request to you'll be shown the content of

As you can see we have just one rule (instead of 300) which cares about all possible requests and deals with all existing mapfiles.

Tuesday, January 19, 2010

Helicon Ape Happy new build!

Hello, everyone!
Happy holidays!
We've got some good news for you—the new build of Helicon Ape 3 is released and available for download.
And it's not just a couple of bug-fixes; we've introduced:
  • three new modules:
    • mod_dbd which allows creation and management of SQL database connections;
    • mod_authn_dbd which provides user authentication by searching users in SQL tables; and
    • mod_dir which cares about "trailing slash" redirects and directory index files handling;
  • really important and highly anticipated by the clients ErrorDocument directive that gives a possibility to set custom error pages upon error;
  • two parameters for Options directive:
    • ShowErrorInResponse which tells Ape to show detailed error explanation or omit it;
    • StopOnError which regulates whether to ignore unknown directives or give out 500 error;
  • some important fixes, in mod_linkfreeze in particular.