Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    htaccess directory listing error.

    In my directory, i have a .htaccess file with the following:

    PHP Code:
    Directory Index index.php

    <Files testgd.jpg>
    ForceType application/x-httpd-php
    </files>

    <
    Files stats2.jpg>
    ForceType application/x-httpd-php
    </files
    And i am getting an internal server error. What do i change?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Hi,

    Sorry, what exactly are you trying to do? List files in the dir? I don't think im following you but if I am ...

    To list files in a dir using htaccess file you will need...

    Options +Indexes
    This sets enables directory listings. And then you will need to list them with
    thisOptions -Indexes
    Cheers
    P

  • #3
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    what im trying to do, is if you go to that directory, it forces you to go to index.php if there is one in that folder.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Ok, in which case you need ..

    .htaccess
    Code:
    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^ /index.php
    That will send all traffc to the dir it is in to index.php. That's assuming you want it to send everyone to index no matter what file within that dir they are trying to access.

    Or .. are you trying to set an index on the dir? In which case .htaccess file is not important, just use what you have already got ...
    Code:
    DirectoryIndex index.php
    ... though make sure you are setting Directory Index in the right place in http.conf. After you have done that, if it is still not working you will need to restart Apache.

    One of those is bound to be what you are after, right?
    Sir P
    Last edited by sir pannels; 01-13-2006 at 04:29 PM.

  • #5
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    It's "DirectoryIndex" not "Directory Index".

    Code:
    DirectoryIndex index.php
    
    <Files testgd.jpg>
    ForceType application/x-httpd-php
    </files>
    
    <Files stats2.jpg>
    ForceType application/x-httpd-php
    </files>

  • #6
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    directory index is what i had, not directoryindex. And it doesn't work. My apache configuration only goes to a index.html not index.php and my host will not change it.

  • #7
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    directory index is what i had, not directoryindex. And it doesn't work.
    It's supposed to be all one word, "DirectoryIndex". And you can put it in your .htaccess file, you host doesn't need to change it.

    Or are you saying "DirectoryIndex" doesn't work?

    Edit: The code in my last post should work fine.

  • #8
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    okay, i made it one word and im getting:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, admin@rapdat.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

  • #9
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    What is in your .htaccess file? (Something else that could be messing it up?)

    Have you tried this in you .htaccess file on it's own? Does it work?
    Code:
    DirectoryIndex index.php index.html index.htm
    If not, maybe they don't allow you to change this.

    A mod_rewrite that _might_ work: (put it in your root directory)
    Code:
    RewriteEngine On
    
    # if the request is for a directory
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    # and there's an index.php in that directory
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}index.php -f
    # give them index.php
    RewriteRule .* %{REQUEST_URI}index.php [QSA,L]

  • #10
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    ok, the first one didn't work, the second one...well...it didn't cause an error.

    MY FILE:

    PHP Code:
    RewriteEngine On

    # if the request is for a directory
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    # and there's an index.php in that directory
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}index.php -f
    # give them index.php
    RewriteRule .* %{REQUEST_URI}index.php [QSA,L]

    <
    Files testgd.jpg>
    ForceType application/x-httpd-php
    </files>

    <
    Files stats2.jpg>
    ForceType application/x-httpd-php
    </files
    and it doesn't do anything. I can still view the directory.

  • #11
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    I don't know why they don't work, they both should (they did for me). I think you should talk to your host about it, maybe they know of a way that'll work on their servers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •