AWstats and apache redirect

I have set up awstats on a test server and it is working successfully. Currently to access the stats the following address has to be used:
http://server/awstats/awstats.pl?config=config-name

I would like to simplify this so that just using http://server/awstats redirects to http://server/awstats/awstats.pl?config=config-name

I am running Ubuntu server 10.04 and the LAMP stack is set up from the option in the Ubuntu installer.
The only change I have tried to make to the modules from default is a2enmod rewrite, however the output of apache2ctl -l did not change after running this command.

I am looking at the file /etc/apache2/sites-available/default config file
I think I need something like the following:

ScriptAlias /awstats/ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name
      <Directory "/usr/local/awstats/wwwroot/cgi-bin/">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
      </Directory>

So not only do I want a particular perl script to be run, I want a particular config file passed to it, but I'm not sure I can do that with scriptalias as all I have managed to do so far is stop my original working path (http://server/awstats/awstats.pl?config=config-name) from working at all.

Can anyone point me in the right direction please?
LVL 5
QEMSAsked:
Who is Participating?
 
robsz1Commented:
Hello QEMS,

Try this in your apache configuration.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^/awstats$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name
</IfModule>
0
 
QEMSAuthor Commented:
Thanks for your suggestion robsz1, unfortunately it hasn't worked though.
I have tried it both with and without my previous entry in /etc/apache2/sites-available/default (restarting apache between each change)

I tried your suggestion in /etc/apache2/apache2.conf is that the right config file?

The other thing I am thinking is that I don't see mod_rewrite.c as part of the output from apache2ctl -l
Am i likely to need to enable that another way? Or can you suggest another way to make sure that everything is set up the way it needs to be?
0
 
QEMSAuthor Commented:
OK - mistake on my part.

I have made the change you suggested in /etc/apache2/sites-available/default and removed it from apache2.conf

I have also removed my original attempt.

There is now a different result - but I get an access forbidden message.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
QEMSAuthor Commented:
If I try to access http://server/awstats/ (with the trailing /) I get the 403 forbidden error.
Is it possible to avoid this? No major problem though.

If I use http://server/awstats (without the trailing /) then the browser tries to download the awstats file.
Do I need to make it the script executable?

Do I still need something like the following?
      <Directory "/usr/local/awstats/wwwroot/cgi-bin/">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
      </Directory>
0
 
robsz1Commented:
QEMS,

Try chaning the line:
RewriteRule ^/awstats$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name

to:
RewriteRule ^/awstats/$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name [R]


The first change here makes it so that the / at the end has to be there after /awstats
The second change is the [R] which should tell the client to make a new request for the page.
0
 
QEMSAuthor Commented:
Thanks for your suggestion, could I also do the following?

RewriteRule ^/awstats$ /awstats/
RewriteRule ^/awstats/(.*)$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name [R]

I'll test your suggestion first and then try my ammendment.
0
 
QEMSAuthor Commented:
Ok I tried that and had a problem - but I spotted in the browser that it was trying to redirect me to
http://server/usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name

Whereas the path that worked (but required "awstats.pl?config=config-name" to be added at the end - this was what I wanted to simplify) was:
http://server/awstats/awstats.pl?config=config-name

So I changed
RewriteRule ^/awstats/(.*)$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl?config=config-name [R]
to the following two lines:
RewriteRule ^/awstats$ /awstats/
RewriteRule ^/awstats/(.*)$ /awstats/awstats.pl?config=config-name [R]

and everything is working as I hoped for - thanks very much.

I must have a setting somewhere (probably set by the awstats install script) that I haven't spotted that is already directing "/usr/local/awstats/wwwroot/cgi-bin/" to /awstats/
0
 
QEMSAuthor Commented:
Thank you very much for your help robsz1
0
 
QEMSAuthor Commented:
Just as a follow-up, I checked and the awstats_configure.pl does modify httpd.conf, it adds thre alias entries and one scriptalias entry.

The scriptalias entry is as follows:
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

So at least I now know why I had to direct to /awstats/ instead of /usr/local/awstats/wwwroot/cgi-bin/ and i also know where that entry is :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.