Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
.htaccess and awstats
I’ve posted a similar topic back in september but with no results. Found some workarounds in the end but they stopped working with the 4.0.1 upgrade.
I am running TXP 4.0.1 r888 and I can’t seem to get AWstats to run with TXP’s .htaccess:
<pre><code>#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options +SymLinksIfOwnerMatch
#RewriteBase /textpattern
<IfModule mod_rewrite.c> RewriteCond %{REQUEST_URI} ^/awstats/(.*)$ [OR]
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L] RewriteRule ^(.*) index.php </IfModule>php_value register_globals off</code></pre>
I can access http://domain.com/awstats/ without any probs (same for any other files within it EXCEPT the .pl ones), but when I go http://domain.com/awstats/awstats.pl apache says Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /home/httpd/vhosts/domain.com/httpdocs/awstats/awstats.pl.
I have been reading quiet a few posts over here (TXP works but other scripts dont work because TXP. mod_rewrite issue?, Stats page redirects to main) but things just don’t work for me. I even tried putting Options +FollowSymLinks and Options +SymLinksIfOwnerMatch in .htaccess but it still won’t work.
Any help will be appreciated. Cheers!
[Oh, forgot to mention that by uncommenting everything that is in the IfModule directive, AWstats works fine.]
Last edited by gerhard (2005-11-12 12:28:12)
Offline
#2 2005-11-12 17:04:54
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
Your awstats line is placed before RewriteEngine On, so url rewriting is not enabled at the time that line is executed. Try placing it just after it.
But also – does the awstats directory exist? If so, your rule should be unnecessary. The first set of Textpattern rewrite rules (the three lines prior to RewriteRule ^(.*) index.php) are there to allow passthrough for all requests for files or directories that actually exist in the filesystem.
Offline
Re: .htaccess and awstats
Yes Andrew, you are right, there is no need for rewrite rules because the directory is already there. However, when I try accessing http://domain.com/awstats/awstats.pl?conf=domain.com, it keeps giving 403s with the error I’ve mentioned in my first post (FollowSymLinks etc.).
Even plain <em>.pl</em> files (no <em>?=conf</em> etc. afterwards) it doesn’t like.
If I comment ALL rewrite rules & conditions, it works fine:
<pre><code>#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options +SymLinksIfOwnerMatch
#RewriteBase /textpattern
<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteCond %{REQUEST_URI} ^/awstats/(.*)$ [OR]
#RewriteCond %{REQUEST_URI} ^/awstats/awstats.pl?conf=domain.com$ [OR]
#RewriteCond %{REQUEST_FILENAME} -f [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteRule ^(.+) – [PT,L]
#RewriteRule ^(.*) index.php
</IfModule>
php_value register_globals off</code></pre>
I have a feeling the dots that appear in the URI are screwing with it (<em>.pl</em> and then <em>.com</em>). But why doesn’t it like plain <em>.pl</em> files either? It works fine with <em>.txt</em> or <em>.pm</em> files…
The whole thing feels like one of Apache’s top 10 mysteries.
Cheers mate ; ).
Last edited by gerhard (2005-11-12 18:02:23)
Offline
#4 2005-11-12 17:45:49
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
Could be a permissions thing – since it’s a cgi script it needs to be chmod 755 doesn’t it?
Offline
#5 2005-11-12 17:50:11
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
Oh wait, so that means you got it working?
Offline
Re: .htaccess and awstats
Chmodded everything in <code>httpdocs</code> that starts with <code>aws*</code> to <code>755</code> but still nada.
I think we need here either Zem, Sencer or Mary. : )
##########################################################
Heck you’re fast (I didn’t get to reply to the first one and you already posted another one).
Yes, it works fine IF I comment the rewrite bit in TXPs .htaccess. This however breaks clean URL support (something I don’t want to do).
Last edited by gerhard (2005-11-12 17:58:30)
Offline
#7 2005-11-12 17:57:41
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
You said that when you uncommented all rules, it worked. FollowSymLinks may be the key.
Edit: Ok, so you meant only if you remove all of Textpattern’s fiddly bits. Hm… if I had more experience with AWStats I’d be of more help. It is such a pain to setup.
Last edited by Andrew (2005-11-12 17:59:36)
Offline
#8 2005-11-12 18:05:52
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
Btw, I think something is needed for your AWStats install directory…
Options +FollowSymlinks +ExecCGI
AddHandler cgi-script cgi pl
DirectoryIndex awstats.pl
Also, what happens when you uncomment Options +FollowSymLinks in the default Textpattern .htaccess, without adding any AWS rules?
Last edited by Andrew (2005-11-12 18:12:31)
Offline
#9 2005-11-12 18:25:18
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: .htaccess and awstats
One last attempt. Is your awstats directory aliased? If so, it doesn’t really exist under your rewritebase does it? What if you try something like this (pulled from a forum I read about someone under WordPress who experienced the same problem as you’re experiencing):
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options +SymLinksIfOwnerMatch
#RewriteBase /textpattern
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/awstats/
RewriteRule .* - [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
php_value register_globals off
.
Offline
Re: .htaccess and awstats
Nope, it doesn’t work. BUGGER!
Uncommenting <code>Options +FollowSymLinks</code> was the first thing that I did after checking the logs. Needless to say it didn’t work…
Well, after having spent almost 1 day with this bastard, I think it’s time to take a shortcut: put awstats in a subdirectory. I still think it’s worth getting to the bottom of this though. Unfortunately, I don’t have more time for this bugger.
Cheers Andrew, you’re a star ; ).
###########################################
Tom Raftery’s tip, yep. This AWstats issue is so bloody frustrating!
No, awstats dir is the app itself. Didn’t really want symlinks pointing up my server’s public tree. It uses more space, but it’s more secure this way (or so <em>methinks</em>).
Last edited by gerhard (2005-11-12 18:36:05)
Offline
#11 2005-11-12 21:28:20
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: .htaccess and awstats
Try setting RewriteBase to /, and/or removing the leading slash from ^/awstats/. mod_rewrite is like this – there’s no solution that works everywhere. Keep experimenting and read the docs (but bear in mind they’re sometimes wrong).
Alex
Offline
Re: .htaccess and awstats
hi gerhart, could it be, that the server indeed has no right to read awstats (the dir)? the 403 at the beginning says something like this. the rewrite-rules
RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -dshould catch the dir. and it seems that they do.
try the original .htaccess again but set Loglevel to 10 and look into the log.
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteloglevel
Samui? Samui! (about the life as farang in thailand)
David’s Neighbour
Offline
Re: .htaccess and awstats
Hey guys ; ).
Zem
Played with your suggestion for a bit but got nowhere.
Graumeister
Made what you suggested (set the level to 3 – didn’t want to kill the server : )) and this is the output:
<code>xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (2) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] rewrite images/domain_r1_c2.gif -> index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] add per-dir prefix: index.php -> /home/httpd/vhosts/domain.com/httpdocs/index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (2) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip document_root prefix: /home/httpd/vhosts/domain.com/httpdocs/index.php -> /index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (1) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] internal redirect with /index.php [INTERNAL REDIRECT]
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#847fcb8/initial/redir#1] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip per-dir prefix: /home/httpd/vhosts/domain.com/httpdocs/index.php -> index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#847fcb8/initial/redir#1] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] applying pattern ‘^(.+)’ to uri ‘index.php’
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#847fcb8/initial/redir#1] (2) forcing ‘/home/httpd/vhosts/domain.com/httpdocs/index.php’ to get passed through to next API URI-to-filename handler
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#847fcb8/initial/redir#1] (1) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] initial URL equal rewritten URL: /home/httpd/vhosts/domain.com/httpdocs/index.php [IGNORING REWRITE]
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip per-dir prefix: /home/httpd/vhosts/domain.com/httpdocs/images/domain_r1_c6.gif -> images/domain_r1_c6.gif
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] applying pattern ‘^(.+)’ to uri ‘images/domain_r1_c6.gif’
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip per-dir prefix: /home/httpd/vhosts/domain.com/httpdocs/images/domain_r1_c6.gif -> images/domain_r1_c6.gif
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] applying pattern ‘^(.*)’ to uri ‘images/domain_r1_c6.gif’
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (2) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] rewrite images/domain_r1_c6.gif -> index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] add per-dir prefix: index.php -> /home/httpd/vhosts/domain.com/httpdocs/index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (2) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip document_root prefix: /home/httpd/vhosts/domain.com/httpdocs/index.php -> /index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84703e0/initial] (1) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] internal redirect with /index.php [INTERNAL REDIRECT]
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84e87c0/initial/redir#1] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] strip per-dir prefix: /home/httpd/vhosts/domain.com/httpdocs/index.php -> index.php
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84e87c0/initial/redir#1] (3) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] applying pattern ‘^(.+)’ to uri ‘index.php’
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84e87c0/initial/redir#1] (2) forcing ‘/home/httpd/vhosts/domain.com/httpdocs/index.php’ to get passed through to next API URI-to-filename handler
xx.xxx.xx.xxx – - [15/Nov/2005:05:36:31 —0500] [www.domain.com/sid#81c82a0][rid#84e87c0/initial/redir#1] (1) [per-dir /home/httpd/vhosts/domain.com/httpdocs/] initial URL equal rewritten URL: /home/httpd/vhosts/domain.com/httpdocs/index.php [IGNORING REWRITE]</code>
Willing to translate that mumbu jumbo into plain English? : )
Last edited by gerhard (2005-11-15 10:41:41)
Offline
Re: .htaccess and awstats
I looked at the installation instructions for awstats, and it uses Alias and Scriptalias in httpd.conf to match requests to its’ scripts. That’s why
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
is not catching it, because the request does not match a file or directory, but is translated by Apache. You can try to replace the above two lines (from a stock .htaccess in textpattern) with the following:
RewriteCond %{REQUEST_FILENAME} -U
From the manual:
Checks if TestString is a valid URL and accessible via all the server’s currently-configured access controls for that path. This uses an internal subrequest to determine the check, so use it with care because it decreases your server’s performance!
Though I have no experience with how noticable the effect would be.
Offline
Re: .htaccess and awstats
Sencer, thanks mate for chipping in. Tried your suggestion but it still won’t work <code>Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /home/httpd/vhosts/domain.com/httpdocs/awstats/awstats.pl</code>
The approach that I resorted to is having another subdomain (e.g. stats) for every website that has AWstats running. I’ve also made AWstats available from cgi-bin (reluctantly because a lot of exploiters are probing this dir).
Approaching the issue from another angle was much easier than trying to sort Apache skets out.
Cheers to everyone contributing towards the solution ; ).
Offline
Pages: 1