Profile

unixronin: Galen the technomage, from Babylon 5: Crusade (Default)
Unixronin

December 2012

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829
3031     

Most Popular Tags

Expand Cut Tags

No cut tags

July 13th, 2007

unixronin: Closed double loop of rotating gears (Gearhead)
Friday, July 13th, 2007 08:05 pm

Let me keep this short:  I'm trying to do something fairly simple with mod_rewrite on Apache 1.3.x, and mod_rewrite isn't cooperating.  As a matter of fact, mod_rewrite isn't doing ANYTHING.

Consider the following sample directives:

RewriteEngine On

RewriteLog /tmp/apache-rewrites

RewriteLogLevel 9

RewriteCond %{REQUEST_URI} .*babcom.* [NC]

RewriteRule ^/(.+) http://www.caerllewys.net/$1 [R]

It should be apparent that this test rule should simply munge any URL containing the string 'babcom' and redirect it to caerllewys.net.  (I don't care at this point whether the resulting URL is valid, I just want it to do SOMETHING.)

So, we turn the rewrite engine on.  We tell mod_rewrite to log to /tmp/apache-rewrites at log level 9, and it obligingly opens the log file.

And that's the last thing it ever does.  mod_info says the module is loaded and has parsed its rules.  But it's not doing ANYTHING.  It never rewrites, and it never logs a thing.

Have any of you geekly types ever run into this behavior before?  Am I missing something stupidly, blindingly obvious?  Is there some secret, undocumented restriction against using both mod_rewrite and mod_alias?  Does Apache just hate me?

Update:

Problem is solved.  The Apache documentation never mentions that if you're running vhosts, mod_rewrite directives need to go in the vhost sections, not in the global section.

Tags: