Add Rewrite Rule Plugin - Documentation topics on: dynamic plugins,mod_rewrite,osgi,tuckey,urlrewrite,url rewrite filters,.

Add Rewrite Rule Plugin

This bundle plugin is an example of how add Tuckey rewrite rules using an OSGI bundle plugin. For more information about Tuckey rewrite rules, please see the URL Rewrite Rules documentation.

Implementation Steps

This plugin is located in the com.dotcms.tuckey subdirectory in the examples directory (/dotCMS/docs/examples/osgi/com.dotcms.tuckey).

To implement the plugin, you must do the following:


To be able to deploy the plugin, you must specify the following in the META-INF/MANIFEST.MF file (please see the template plugin for examples):

Bundle-NameThe name of your bundle.
Bundle-SymbolicNameA short an unique name for the bundle.
Bundle-ActivatorPackage and name of your Activator class (example: com.dotmarketing.osgi.tuckey.Activator).
DynamicImport-PackageDynamically add required imports the plugin may need without add them explicitly.
Import-PackageThis is a comma separated list of package's name.
List the packages that you are using inside the bundle plugin and that are exported by dotCMS.


In order for the plugin to work inside the Apache Felix OSGI runtime, the import and export directives must be bidirectional.

Source Folder

The src folder (/src/com/dotmarketing/osgi/tuckey/ in the plugin folder) contains the Java classes needed to create Tuckey rewrite Rules in dotCMS - and

The bundle activator extends from com.dotmarketing.osgi.GenericBundleActivator and implements BundleActivator.start(). It manually registers Tuckey Rewrite Rules, making use of the method addRewriteRule.


  • unregisterServices() must be called in the stop method.
    • This call is MANDATORY as it stops and removes the register Quartz Job when the plugin is undeployed.

This is a simple and standard implementation of an HttpServlet used to test the added Tuckey Rewrite Rules.

Update Exported Packages

Your OSGI plugins may access any dotCMS packages which have been exported. When you add the rewrite plugin, you must add the tuckey package to the list of exported packages to ensure your plugin has access to it.

You may update the list of exported packages either through the OSGI Plugins portlet or by manually editing the osgi-extra.conf file.

For more information, please see the Exported Packages section of the OSGI Plugins documentation.


You can test the rewrite plugin in several different ways:

  • Access the simple test servlet built-in to your dotCMS instance:
  • Test the forward rule:
  • Test the redirect rule:
  • Test the conditions:
    • Note: If you call this using google Chrome, it will display the message “from google Chrome”
    • Otherwise it will do nothing (404 error).


You can enable logging to help in troubleshooting any issues. To enable logging, add the following lines to the web.xml file ():



  • It is strongly recommended that all changes to the web.xml file be made through a properties file extension.
  • Enabling logging generates a large number of log messages.
    • Logging should be used for testing and troubleshooting only.
    • Logging should be disabled for production systems.

Fore more information on OSGI plugin logging, please see the OSGI Plugin Logging documentation.