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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.