Making /stats accessible

Some 3rd party apps like Typo, WordPress, and Drupal will take over the directory .htaccess file where they are installed to provide nice and clean urls but doing so can break your /stats and other aliased requests.

The problem occurs because mod_rewrite is used to redirect all requests for non-existing files to the default file the CMS or program uses. A lot of hosting providers will install a stats package like Awstats for you, but instead of installing into your site directory they create a link or redirect.

Some examples follow, substitute stats for your situation. These examples all assume that they are in the .htaccess file created by your 3rd party app.

For Drupal

Drupal Home

# Rewrite URLs of the form 'index.php?q=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/stats [NC]
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

For Mambo

Mambo Home

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/stats [NC]
RewriteRule . /index.php [L]

For WordPress

WordPress Home

RewriteCond %{REQUEST_URI} ^/stats [NC]
RewriteRule . - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

For Typo

Typo Home

RewriteRule ^xml/([a-z]+)$ /xml/$1/feed.xml [R=301]
RewriteRule ^$ /index.html [QSA]
RewriteRule ^([^.]+)$ /$1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/stats [NC]
RewriteRule . dispatch.fcgi [QSA,L]

For DokuWiki

DokuWiki Home

RewriteEngine On
RewriteBase /dokuwiki/

RewriteRule ^_media/(.+) /lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.+) /lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.+) /doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ /doku.php  [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/stats [NC]
RewriteRule ^(.+)$ /doku.php?id=$1 [QSA,L]
RewriteRule ^index\.php$ /doku.php

RewriteStatsBroken (last edited 2009-09-20 22:13:21 by localhost)