.htaccess Dir Listing Only Redirect

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

.htaccess Dir Listing Only Redirect

Post by CoderGoblin »

Hello All,

Put simply I want to use redirect only when on the Directory listing to the home page when in a sub-directory where the .htaccess used to be RewriteEngine off and the root directory points everything to a specific php script (Zend Framework setup).

The directory and .htaccess files are as follows

Code: Select all

Root
  .htaccess
  application directory
  public directory
        .htaccess
The root/.htaccess is

Code: Select all

RewriteEngine on
RewriteBase /~user/application
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Under the public directory with the aid of Google I changed the .htaccess to, rather than just "RewriteEngine off":

Code: Select all

RewriteEngine off
Options -Indexes
I then get a error 500 when trying to view the directory without any file information. What I really want to do is redirect to the index.php at the top level if directory listing but allow any files access if referenced directly. I need to "ignore" any redirects defined in the initial .htaccess.

Hopefully this makes sense and someone has come across the problem/solution before. If they can either give me a solution or point me in the right direction (and I don't mean the apache .htaccess documentation as I have looked at that already and come away more confused than ever 8O ).

Thanks in advance
Post Reply