I've got mod rewrite enabled, and I'm running drupal at "staging.example.com/drupal"; drupal is just a symlink to drupal-5.2

Everything works fine with the exception of Clean URLs. If I tweak my Apache config to read "AllowOverride All" clean URLs work just fine, but for a number of reasons (primary among them that I inherited a heavily customized server from a predecessor and it is running a great many different little scripts and plug-ins and I don't like the idea of opening up everything) I would rather limit overrides to the Drupal directory.

According to Apache (http://httpd.apache.org/docs/2.0/mod/core.html#directory) I can use multiple calls in one Virtual Host, but I can't get it to work. Here's what I've got:

## I know it isn't php, but the tag seems to let me cut and paste straight from my config file so I'm going with it.
<VirtualHost *:80>
  ServerAdmin amanda@example.com
  ServerName  staging.example.com
  DocumentRoot /srv/apache2/staging/html
  ScriptAlias /cgi-bin/ "/srv/apache2/staging/cgi-bin/"
  Directoryindex index.shtml index.html index.php index.htm 
  <directory /srv/apache2/staging/>
    Options Indexes FollowSymLinks MultiViews +Includes
    AllowOverride None
    Order allow,deny
    Allow from all
  </directory>

 <Directory /srv/apache2/staging/drupal.*/>
        Options +ExecCGI 
        AllowOverride All 
        Order allow,deny
        Allow from all
 </Directory>
      <Location /community>
      ForceType application/x-httpd-php
      </Location>

      <Location /magazine>
      ForceType application/x-httpd-php
      </Location>

      <Location /tools/email>
      ForceType application/x-httpd-php
      </Location>

      <Location /tiny>
      ForceType application/x-httpd-php
      </Location>

## actually, there are more of these

	RewriteEngine on

	RewriteRule /foo/index.shtml /city/index.php
	RewriteRule /foo/the_record.shtml /city/record.php
	RewriteRule /subscribe /subscribe.shtml
	RewriteRule /arch.lessons.shtml /archive/201
	RewriteRule /blogs/roundup/rebuilding /blogs/roundup/?cat=1
	RewriteRule /blogs/roundup/yadda /blogs/yadda
	RewriteRule /blogs/roundup/yadda/ /blogs/yadda
	RewriteRule /calendar.shtml /events
	RewriteRule /chat/chat_transcripts.shtml /chat/transcripts/
	RewriteRule /community/index.php /community/
	RewriteRule /justice /article/current/4
	RewriteRule /foo/voting_records.shtml /city/vote_records.php
	RewriteRule /tools/calendar_submit.php /events/publicform.php
	RewriteRule /topics.shtml /topics.php


  ErrorLog /var/log/httpd/staging_error.log
  LogLevel warn
  CustomLog /var/log/httpd/staging_access.log combined
  ServerSignature On
</VirtualHost>

I'd love (love) suggestions about how to get this working without just saying "AllowOverride All" -- I'm clearly doing something wrong. I'd love to know what!

Comments

amanda’s picture

Variations that don't work any better:

Switching "AllowOverride" for the whole site to "FileInfo" ought to allow directives controlling mod_rewrite rules but what it actually did was lock me out of drupal altogether with an error like "[Thu Oct 25 ... ] /srv/apache2/staging/html/drupal/.htaccess: order not allowed here" (in this case I commented out the second directory directive.

      7   <directory /srv/apache2/staging/>
      8     Options Indexes FollowSymLinks MultiViews +Includes
      9     AllowOverride FileInfo
     10     Order allow,deny
     11     Allow from all
     12   </directory>

Next up: reworking my regular expression a bit ...

     13   <directory ~ "/home/webmaster/staging/drupal.*/">
     14         Options +ExecCGI
     15         AllowOverride All
     16   </directory>

Before discovering a gem of a box on the documentation, to the tune of ...

Only available in <Directory> sections
AllowOverride is valid only in <Directory> sections specified without regular expressions, not in <Location>, <DirectoryMatch> or <Files> sections.

(As ever, the php tags are mine, and just there so's I can paste formatted snippets without fixing all the > and <)

So I'm not quite back to the drawing board, but I might resort to just AllowOverride All, which is what I'm trying to avoid here.