Installing Awstats on a Rails Site

wordpress

#1

Hi,
I’m in the process of setting up awstats on a Ruby on Rails site. From what I can tell, awstats is working just fine. The problem comes up when I try to navigate to the awstats URL (mydomain.com/statistics/). When I try to do that, the Rails URL rewriting kicks in and tries to find an action to correspond to a nonexistent controller called “statistics”.

I know I have to alter .htaccess in the /public folder to change the URL rewriting behavior. What I don’t know is what to modify it to.

Does anyone have any experience with hacking .htaccess to get awstats to work with Rails?

Thanks,
Rick


#2

Sounds similar to what happens in WordPress. You should already have a .htaccess file. Maybe you can tailor WP’s setup to work for Rails. This rewrite precedes the existing rules by not rewriting, and then exiting the rewrite process.

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/failed_auth.html$ RewriteRule ^.*$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress

-Scott


#3

sdayman is right… Here’s the exact portion from one of my Rails app’s .htaccess. Look for the part [near the top] of .htaccess that says

If you don’t want Rails to look in certain directories,

use the following rewrite rules so that Apache won’t rewrite certain requests

Example:

RewriteCond %{REQUEST_URI} ^/notrails.*

RewriteRule .* - [L]

and add the lines:

RewriteCond %{REQUEST_URI} ^/SOME_DIR.*
RewriteRule .* - [L]

after it. Make sure you substitute your awstats or whatever dir for “SOME_DIR”.