views:

80

answers:

2

I have in the past successfully managed to copy/edit/paste rewrite rules on an apache server over which I had limited control.

Now however I am experimenting with an Apache server which I can restart and configure to my heart's content but I cannot get even a basic rewrite example to work and that is after I have read at least two tutorials. I have played with LogLevel and RewriteLog but I can find no real evidence that my really basic rewrite rules are being used. My rewrite log file was created but its empty. I have also tried commenting out every thing from httpd.conf but the rewrite stuff.

Let's see what other information I can add:

chilcott:/etc/apache2/conf.d# uname -a
Linux chilcott 2.6.26-1-486 #1 Sat Jan 10 17:46:23 UTC 2009 i686 GNU/Linux


chilcott:/etc/apache2/conf.d# apache2ctl -V
Server version: Apache/2.2.9 (Debian)
Server built:   Jan 20 2009 17:29:25
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.2.12, APR-Util 1.2.12
Compiled using: APR 1.2.12, APR-Util 1.2.12
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT=""
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
+1  A: 

Do you have your rewrite rules under the right section of your httpd.conf? They should probably be in a vhost section.

Posting your httpd.conf (or at least some of it) might help.

It should look a bit like this:

LoadModule rewrite_module modules/mod_rewrite.so

RewriteLogLevel 9
RewriteLog ".....rewrite.log"


<VirtualHost *:80>
    DocumentRoot "..."

    RewriteEngine On
    RewriteRule ^/foo /bar
</VirtualHost>
Greg
Thanks. That has given me some useful pointers. Presumably following the standard Debian configuration we have:<pre># Include module configuration:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf</pre>This is certainly intended to do the LoadModule bit and I have now satisfied myself that that bit is working.The useful clue was in the VirtualHost bit. I had tried putting the rules in either the top-level file or the .htaccess. I think I was having too many moving parts for the latter to work. Copying my rules to the VirtualHost section has made it work.
asparagus
A: 

You need to load the module to use it. Look into your httpd.conf file for a line like the following and remove the leading comment character # if there is any:

#LoadModule rewrite_module modules/mod_rewrite.so

Then you just need restart your Apache server.

Gumbo
As per other comment this was not the issue.
asparagus