...

View Full Version : htaccess directory listing error.



thesavior
01-13-2006, 01:05 AM
In my directory, i have a .htaccess file with the following:


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?

sir pannels
01-13-2006, 01:13 PM
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

thesavior
01-13-2006, 04:01 PM
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.

sir pannels
01-13-2006, 04:45 PM
Ok, in which case you need ..

.htaccess

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 ...


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

schleppel
01-13-2006, 05:00 PM
It's "DirectoryIndex (http://httpd.apache.org/docs/1.3/mod/mod_dir.html#directoryindex)" not "Directory Index".


DirectoryIndex index.php

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

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

thesavior
01-14-2006, 03:00 AM
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.

schleppel
01-14-2006, 01:55 PM
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.

thesavior
01-14-2006, 05:47 PM
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.

schleppel
01-14-2006, 06:16 PM
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?

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)

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]

thesavior
01-14-2006, 06:48 PM
ok, the first one didn't work, the second one...well...it didn't cause an error.

MY FILE:


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.

schleppel
01-14-2006, 07:00 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum