LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-09-2011, 09:04 AM   #1
daggett
LQ Newbie
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: Manjaro
Posts: 19

Rep: Reputation: 0
How to log Apache mod_rewrite


All that I could find about logging Apache2 mod-rewrite rewrites is confusing and contradictory.

Most (e.g. http://www.easymodrewrite.com/guide-logging) inform me that the way I have installed it on my Linux Mint desktop testbed server is correct (see mod_rewrite directives included below in /etc/apache2/conf.d/testbed3.conf):
Alias /testbed3 /usr/share/testbed3
<Directory /usr/share/testbed3/>
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride All
order allow,deny
allow from all
<IfModule mod_rewrite>
RewriteEngine on
RewriteBase /testbed3/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?q=$1 [L,QSA]
RewriteLog "/var/log/apache2/testbed3Rewrite.log"
RewriteLogLevel 9
</IfModule>
</Directory>
... even though it fails to even create the log file, let alone write output.

This failed to produce any output.

The Apache web-site LogLevel Directive documentation tells me this is how to do it:
LogLevel info mod_rewrite:debug
... or:
LogLevel mod_rewrite:debug
... in place of the RewriteLog and RewriteLogLevel directives shown above. (Note: no separate RewriteLog specified this time.)

Yet, when I put in either of these directives, I still failed to see any output (this time in /var/log/apache2/access.log) that looked anything like mod_rewrite log statements.

Can anyone tell me how to get mod_rewrite logging to work (so I can debug my Drupal content-managed web-site), or point me to documentation which will show me how to do it?

Thanks for your attention.
 
Old 10-09-2011, 09:14 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,275

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Code:
RewriteEngine on
...
RewriteLog "/var/log/apache2/testbed3Rewrite.log"
RewriteLogLevel 9
Is sufficient for logging.
Do you have module mod_rewrite loaded in Apache? Did you restarted Apache after changes? Did you created directory "/var/log/apache2"?

Last edited by eSelix; 10-09-2011 at 09:19 AM.
 
Old 10-09-2011, 09:38 AM   #3
daggett
LQ Newbie
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: Manjaro
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks eSelix, for your response:

You asked:
Quote:
Do you have module mod_rewrite loaded in Apache? ...
Yes:

Code:
tibrogargan apache2 # pwd
/etc/apache2
tibrogargan apache2 # ls mods-enabled/
alias.conf            autoindex.conf  mime.conf         rewrite.load
...
tibrogargan apache2 # cat  mods-enabled/rewrite.load 
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
You asked:
Quote:
... Did you restart Apache after changes? ...
Yes:

Code:
tibrogargan apache2 # /etc/init.d/apache2 restart
* Restarting web server apache2
... waiting
You asked:
Quote:
... Did you create directory "/var/log/apache2"?
It was created when I installed Linux Mint 11:

Code:
tibrogargan apache2 # ls /var/log/apache2
access.log        access.log.4.gz  error.log.1      error.log.5.gz
...
So, as far as I can see, I have done everything I need to. The only way I can see how to move forward is to compile Apache2 from the source code and put some debugging statements around where it it calls mod-rewrite.

Any othersuggestions for an easier approach would also be most appreciated.
 
Old 10-09-2011, 10:26 AM   #4
daggett
LQ Newbie
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: Manjaro
Posts: 19

Original Poster
Rep: Reputation: 0
mod_rewrite doen't work on Ubuntu either

I just tried to run mod_rewrite on another Linux Desktop computer. It was an Ubuntu machine, rather than a Linux Mint machine.

That seems to preclude a peculiarity of Linux Mint causing the problem. However, Linux Mint is based upon Ubuntu (which is in turn base upon Debian), so just possibly a peculiarity of Ubuntu may be the cause.

I could try installing another Linux distribution (maybe CentOS) on another partition and see if the problem with mod_rewrite remains.
 
Old 10-11-2011, 01:35 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,901

Rep: Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885
Hi,

Try to put the RewriteLog stuff outside a <Directory ..></Directory> part.
If you're using vhosts better put RewriteLog directives inside the vhost stanza

Regards
 
Old 10-11-2011, 10:38 PM   #6
daggett
LQ Newbie
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: Manjaro
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks, bathory.

Firstly, one obvious possible error ins the use of the term 'mod_rewrite' instead of just 'rewrite'. There in no module 'mod_rewrite' in /etc/apache/mods-available, only 'rewrite' (or, rather 'rewrite.load'). My flawed memory (literally speaking - my head was knocked 18 months ago in a road accident) must have caused me to think that 'mod_rewrite' was the syntactically correct way to refer to the 'rewrite' module.

However fixing that and follwing your suggestion did not solve my problem.

I am going go try to get the rewrite module to work on a Debian Linux 6.00 partition, rather than on a Linux Mint or Ubuntu partition and see if that changes anything. If necessary, I will (try to) debug the C source code.

Quote:
Originally Posted by bathory View Post
Hi,
Try to put the RewriteLog stuff outside a <Directory ..></Directory> part.
I have tried that (see APPENDIX 1,), but it didn't work.

Quote:
If you're using vhosts better put RewriteLog directives inside the vhost stanza
Regards
By "the vhost stanza", you mean, for example, "<VirtualHost *:80> ...</VirtualHost>"?

I am not using that on my desktop testbed machine.

Appendix 1

This is /etc/apache2/conf.d/testebed2.conf with suggestion of bathory (crudely) applied. It didn't solve the problem. (I commented out "RewriteBase /testbed2/" because apache complained, "RewriteBase: only valid in per-directory config files".)

Code:
Alias /testbed2 /usr/share/testbed2

           RewriteEngine on
#           RewriteBase /testbed2/
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteRule ^(.*)$ ?q=$1 [L,QSA]
           RewriteLog "/var/log/apache2/testbed2Rewrite.log"
           RewriteLogLevel  debug
<Directory /usr/share/testbed2/>
        Options +FollowSymLinks
        AllowOverride All
        order allow,deny
        allow from all
</Directory>
 
Old 10-12-2011, 01:23 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,901

Rep: Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885
Quote:
RewriteLogLevel debug
Why did you change that (from 9 to debug)? You need a number there to specify verbosity, e.g.
Code:
RewriteLogLevel  9
BTW you can leave the RewriteLog* directives outside the <Directory...></Directory> part, while use the rest of the rewrite directives inside that

Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_rewrite and Apache saifurab Linux - Server 3 09-04-2010 09:08 AM
How to enable Apache mod_rewrite, after apache installed without this modue jCash Linux - Newbie 1 10-24-2006 11:23 AM
Apache Mod_rewrite help! soulsniper Linux - Software 0 01-16-2005 06:23 PM
Apache:mod_rewrite MadMikie Linux - Software 0 08-03-2004 08:33 AM
Apache and mod_rewrite notsoevil Linux - General 0 01-23-2002 02:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration