0

My current url to access my awstats is

http://my.server.com/awstats/awstats.pl?config=foo

I would like to use apache and mod_rewrite to

http://my.server.com/foo

My attempt is

RewriteRule ^(.*) /awstats/awstats.pl?config=$1 [NC]

but I just get a 404.

The error.log doesn't give me much help.

jsmorris
  • 319
  • 2
  • 10

1 Answers1

0

Try adding a $ after so that the entire string is eaten by the regexp, and then use [L] so the rewrite engine knows to stop processing and apply the rule.

Remember to switch on the rewrite engine and set the rewrite base.

RewriteEngine on
RewriteBase /

RewriteRule ^(.*)$ /awstats/awstats.pl?config=$1 [NC,L]
Orbling
  • 20,413
  • 3
  • 53
  • 64
  • I added the $ and the L flag so now my rule is RewriteRule ^/(.*)$ /awstats.pl?config=$1 [NC,L] but now I am getting the awstats.pl file as a plain text file instead of being processed by perl. – jsmorris Nov 24 '10 at 00:10
  • @jsmorris Does it work (ie. run the Perl script properly) when you go to the URL directly? – Orbling Nov 24 '10 at 01:26
  • if I remove the rewrite rule and use the longer url, it works fine. – jsmorris Nov 24 '10 at 16:55
  • @jsmorris Try adding `T=application/x-httpd-cgi` to the options list along with `NC,L` == `[NC,L,T=application/x-httpd-cgi]` - if you are using mod_perl that MIME type might need to be different. – Orbling Nov 24 '10 at 17:45