Apache Brush for the SyntaxHighlighter Evolved WordPress Plugin


Having recently switched from SyntaxHighlighter MT to the SyntaxHighlighter Evolved plugin I was unable to get my custom Apache brush I use for .htaccess and *.conf files to work.

While searching for an answer I happened upon a better although seemingly unfinished version of an Apache brush, but still couldn’t get it work. A little further digging and I learnt that I needed to write a plugin to use a custom brush with SyntaxHighlighter Evolved.

My version of the plugin is based on shApacheConfig.js by Riley Wills and while still very much a work in progress, provides adequate though not exhaustive highlighting. Any suggestions or modifications are extremely welcome.

The plugin defines two valid brush names: apache and conf either of which may be used in a <pre> tag or shortcode like so:

<pre class="brush: apache;">

Using a <pre> tag



Using a shortcode



Installation instructions and further notes on usage can be found in the readme.txt file included in syntaxhighlighter-evolved-apache.zip.

The code snippets below are not necessarily working examples and are intended merely to demonstrate the brush’s highlighting capabilities.

# BEGIN WordPress
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteRule ^index\.php$ - [L]
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]

# END WordPress

Example .htaccess file



# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
ServerRoot "/Applications/XAMPP/xamppfiles"

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbd_module modules/mod_authn_dbd.so

	LoadModule php4_module        modules/libphp4.so
	LoadModule php5_module        modules/libphp5.so

<IfModule !mpm_winnt_module>
	<IfModule !mpm_netware_module>
	User nobody
	Group nogroup

ServerAdmin you@example.com

ServerName localhost

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

# First, we configure the "default" to be a very restrictive set of 
# features.  
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

# This should be changed to whatever you set DocumentRoot to.
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html index.php index.htmls index.htm

# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all

ErrorLog logs/error_log

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    CustomLog logs/access_log common


<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/Applications/XAMPP/xamppfiles/cgi-bin/"

<IfModule cgid_module>
    Scriptsock logs/cgisock

# "/Applications/xampp/xamppfiles/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory "/Applications/XAMPP/xamppfiles/phpmyadmin">
    AllowOverride None
    Options None 
    Order allow,deny
    Allow from all

DefaultType text/plain

<IfModule mime_module>
    TypesConfig etc/mime.type
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddHandler cgi-script .cgi .pl .asp
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

MIMEMagicFile etc/magic

# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
# Some examples:
ErrorDocument 500 "The server made a boo boo."
ErrorDocument 404 /missing.html
ErrorDocument 404 "/cgi-bin/missing_handler.pl"
ErrorDocument 402 http://www.example.com/subscription_info.html

EnableMMAP off
EnableSendfile off

# Server-pool management (MPM specific)
Include /Applications/XAMPP/etc/extra/httpd-mpm.conf

# Multi-language error messages
Include /Applications/XAMPP/etc/extra/httpd-multilang-errordoc.conf

<IfModule ssl_module>
    <IfDefine SSL>
        Include etc/extra/httpd-ssl.conf

# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
<IfModule ssl_module>
	SSLRandomSeed startup builtin
	SSLRandomSeed connect builtin

Include etc/extra/httpd-xampp.conf

# Use name-based virtual hosting.
NameVirtualHost *

# tech-otaku [AllowOveride All for WordPress installs to stop 404 Page Not Found errors. Source: http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks]
<VirtualHost *>
	ServerName macbook.to
	DocumentRoot "/Users/steve/Sites/DOMAINS/tech-otaku.com"
	<Directory "/Users/steve/Sites/DOMAINS/tech-otaku.com">
		Options Indexes FollowSymLinks Includes execCGI
		AllowOverride All
		Order Allow,Deny
		Allow From All

Example .httpd.conf file (XAMPP)



Change Log


0.9.1Fixed Uncaught TypeError in shBrushApache.js2014-06-04
0.9.0Initial Release2013-04-05

About the author

A native Brit exiled in Japan, Steve spends too much of his time struggling with the Japanese language, dreaming of fish & chips and writing the occasional blog post he hopes others will find helpful.

7 responses


  • Hey Steve,

    thanks for the plugin, works like charm! I ran into the need to highlight some Apache-code with my newest blog-post and this came in very handy.

    Keep it up & thanks again!

  • Hi. I’m the author of the Syntax Highlighter MT plugin, and was just curious why you decided to switch away.

    • Hi Chad,

      I actually prefer your implementation over others, but upgrading from v1.0 recently caused problems with code highlighting on this site. I tried SyntaxHighlighter Evolved and apart from a few tweaks it appears to behave better.

      Regards, Steve.

1 Pingback


Recent Comments

Recent Posts