Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-13-2006, 12:05 AM   PM User | #1
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
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?
thesavior is offline   Reply With Quote
Old 01-13-2006, 12:13 PM   PM User | #2
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
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...

Quote:
Options +Indexes
This sets enables directory listings. And then you will need to list them with
Quote:
thisOptions -Indexes
Cheers
P
sir pannels is offline   Reply With Quote
Old 01-13-2006, 03:01 PM   PM User | #3
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
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.
thesavior is offline   Reply With Quote
Old 01-13-2006, 03:45 PM   PM User | #4
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
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..
sir pannels is offline   Reply With Quote
Old 01-13-2006, 04:00 PM   PM User | #5
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
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>
schleppel is offline   Reply With Quote
Old 01-14-2006, 02:00 AM   PM User | #6
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
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.
thesavior is offline   Reply With Quote
Old 01-14-2006, 12:55 PM   PM User | #7
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
Quote:
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.
schleppel is offline   Reply With Quote
Old 01-14-2006, 04:47 PM   PM User | #8
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
okay, i made it one word and im getting:

Quote:
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.
thesavior is offline   Reply With Quote
Old 01-14-2006, 05:16 PM   PM User | #9
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
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]
schleppel is offline   Reply With Quote
Old 01-14-2006, 05:48 PM   PM User | #10
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
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.
thesavior is offline   Reply With Quote
Old 01-14-2006, 06:00 PM   PM User | #11
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
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.
schleppel is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:51 AM.


Advertisement
Log in to turn off these ads.