Print

Print


> How can I write an .htaccess that's path-independent 
> if I like to exclude certain files in that directory, 
> such as index.html?

This is what the Zend Framework uses.  I think it's pretty clever:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d 

  RewriteRule ^.*$ index.php

It basically says that, if the request is for a real, physical file or directory within your application, then Apache should go ahead and serve it up directly.  If it's not, then go ahead and rewrite the request through your script (index.php).

--Dave


==================
David Walker
Library Web Services Manager
California State University
http://xerxes.calstate.edu
________________________________________
From: Code for Libraries [[log in to unmask]] On Behalf Of Godmar Back [[log in to unmask]]
Sent: Wednesday, July 01, 2009 8:47 AM
To: [log in to unmask]
Subject: Re: [CODE4LIB] tricky mod_rewrite

On Wed, Jul 1, 2009 at 10:38 AM, Walker, David <[log in to unmask]> wrote:

> > They can create .htaccess files, but don't always
> > have control of the main Apache httpd.conf or the
> > root directory.
>
> Just to be clear, I didn't mean just the root directory itself.  If
> .htacess lives within a sub-directory of the Apache root, then you _don't_
> need RewriteBase.
>
> RewriteBase is only necessary when you're in a virtual directory, which is
> physically located outside of Apache's DocumentRoot path.
>
> Correct me if I'm wrong.
>

You are correct!  If I omit the RewriteBase, it still works in this case.

Let's have some more of that sendmail koolaid and up the challenge.

How can I write an .htaccess that's path-independent if I like to exclude
certain files in that directory, such as index.html?  So far, I've been
doing:

RewriteCond %{REQUEST_URI} !^/services/tictoclookup/standalone/index.html

To avoid running my script for index.html.  How would I do that?  (Hint: the
use of SERVER variables on the right-hand side in the CondPattern of a
RewriteCond is not allowed, but some trickery may be possible, according to
http://www.issociate.de/board/post/495372/Server-Variables_in_CondPattern_of_RewriteCond_directive.html)

 - Godmar