.htaccess DirectoryIndex set incorrectly

Found a bug? Tell us!!
Post Reply
planigan
Regular
Posts: 5
Joined: Wed Sep 06, 2006 6:36 am

.htaccess DirectoryIndex set incorrectly

Post by planigan »

OK, I'm not sure if this is a "feature" or a "bug".

When URL rewriting is enabled, it writes the following line to the .htaccess file in the s9y root directory.

Code: Select all

DirectoryIndex /index.php
If you have s9y installed in the server root and other packages (say, gallery2) in subdirectories, the applications in subdirectories become inaccessible. Why? Because the .htaccess directives are inherited! That means the DirectoryIndex for every subdirectory is /index.php. It should be just index.php.An example (from my site).

patricklanigan.org/public_html/ <--- s9y installation
patricklanigan.org/public_html/gallery <---- G2 installation

Both www.patricklanigan.org and www.patricklanigan.org/gallery/ would take you to the s9y front page, because it was using the absolute /index.php as the directory index.

I hope you understand my rambling. In anycase, the fix is to replace the above lines with

Code: Select all

DirectoryIndex index.php
It would also be nice if we could specify our own error handlers. Why does s9y do this for me? Just because I use URL rewriting, does not mean I want to use /index.php as my error document![/code]
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Serendipity asssumes all subdirectories under its directory are Serendipity's. This usually works out fine, because anything else that uses redirection will write its own .htaccess, and Apache uses the one from the closest directory.

Other people have had the same complaint you mention, though. The easiest solution is to simply create an .htaccess file in each non-Serendipity subdirectory (assuming the subdirectory in questions doesn't already have one of its own) with the following code:

Code: Select all

RewriteEngine Off
That will cause Apache to ignore the top-level Serendipity redirection rules, including the DirectoryIndex.
Judebert
---
Website | Wishlist | PayPal
planigan
Regular
Posts: 5
Joined: Wed Sep 06, 2006 6:36 am

Post by planigan »

Serendipity asssumes all subdirectories under its directory are Serendipity's.
Erm, OK.
This usually works out fine, because anything else that uses redirection will write its own .htaccess, and Apache uses the one from the closest directory.
Yes, this is fine for redirection because the mod_rewrite directives are not inheretied unless specified. However, all of the other directives in the .htaccess files (including DirectoryIndex) are inherited across subdirectories.

The problem is, not all applications that use redirection set the DirectoryIndex directive. For example, gallery2 does use mod_rewrite, but it does not set DirectoryIndex. So, the "/index.php" value is inherited by the galler2 subdir, screwing things up.
Other people have had the same complaint you mention, though. The easiest solution is to simply create an .htaccess file in each non-Serendipity subdirectory (assuming the subdirectory in questions doesn't already have one of its own) with the following code:
Code:
RewriteEngine Off

That will cause Apache to ignore the top-level Serendipity redirection rules, including the DirectoryIndex.
I saw those posts, and it seems like the problem lies more in s9y's (mis)use of the DirectoryIndex value. I think a better solution is to change the way this value is set, unless there is some functional reason for setting it to the root.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

You're right about the DirectoryIndex thing being inherited. Sorry; I was working tired and misunderstood your post.

Perhaps the more functional reason is so nobody can access the templates/, plugins/, and other directories? Otherwise we'd have to put an .htaccess in each of those directories, which could impact Apache performance (and perceived Serendipity performance).

Instead, we just expect either that all subdirectories of Serendipity will contain only Serendipity files (in which case misaccess is redirected to the blog), or that other applications installed in the Serendipity hierarchy will have their own DirectoryIndex (or have it created for them by the users who do such installs).
Judebert
---
Website | Wishlist | PayPal
Post Reply