Apache Directives

Using a special .htaccess file, you can add many additional server-side tasks, checks and processes to Vanilla CMS.  The current configuration of the .htaccess file contains the following:

  • Domain redirection -  e.g., http://domain.com to http://www.domain.com
  • Deny filter - denies access to the website from known spam sites an IP addresses
  • IE image fix - a directive to prevent Internet Explorer image flickering in certain situations
  • Friendly URLs - a series of regular expressions to redirect page IDs to Friendly URLs
  • Override Magic Quotes - a fix for servers with PHP's magic_quotes turned on
  • Custom error pages - a series of directives for returning server errors (must be added after error pages are created)
  • Disable directory indexing - prevents folders without an index file from showing a list of its contents

Default .htaccess File

Below is the contents of the current .htaccess file. Comments are preceded by a hash symbol #.

# Force PHP5 - for testing purposes only
# AddType x-mapp-php5 .php

# Override magic quotes
php_flag magic_quotes_gpc off 

# Error pages - uncomment to activate
# IMPORTANT! You *must* change the domain and pID to reflect your own actual error pages
# ErrorDocument 401 http://www.vanillacms.com/?pID=108
# ErrorDocument 403 http://www.vanillacms.com/?pID=106
# ErrorDocument 404 http://www.vanillacms.com/?pID=105
# ErrorDocument 500 http://www.vanillacms.com/?pID=107

# Always use www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^vanillacms.com [NC]
RewriteRule ^(.*)$ http://www.vanillacms.com/$1 [L,R=301]

# Friendly url directives
# IMPORTANT! If your site is not under the domain root, this *must* be modified
# For example, if you've installed Vanilla in a directory called 'myfolder':
# RewriteRule ^$ /myfolder/index.php
# RewriteRule (^[-_A-Za-z0-9\ ]*$) /myfolder/?friendly_title=$1 [QSA]
#
# This directive *must* have the [QSA] flag to keep extra query strings intact
RewriteEngine On
RewriteRule ^$ /index.php
RewriteRule (^[-_A-Za-z0-9\ ]*$) /?friendly_title=$1 [QSA]

# Reduce flicker in internet explorer
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000

# Disable indexing
Options -indexes

# Deny access to evil robots, site rippers, offline browsers and other such nasties
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR]
RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR]
RewriteCond %{HTTP_USER_AGENT} ^attach [OR]
RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]