Solved

Directory index forbidden by rule -- Problem

Posted on 2002-07-04
13
64,588 Views
Last Modified: 2011-08-18
I've just installed apache, and if I put in

http://www.website.com/, it says "Forbidden", put if I put in http://www.website.com/index.html, it works??

Also I have a directory called "htdocs" and within that is a file called "index.php". If I put in the browser:

http://www.website.com/htdocs/index.php

It comes back with "Page cannot be displayed" although the path is correct.

When I look in the error_log, nothing appears for the second statemant "/htdocs/index.php" but with the first error (http://www.website.com/") the error log shows the following error:

Directory index forbidden by rule

What does mean, and what can I do to resolve it?
0
Comment
Question by:choccarlm
13 Comments
 
LVL 15

Expert Comment

by:samri
ID: 7130963
Choccarlm,

Forbidden is due to the default config for apache is to be quite restrictive.  You would need to enable directory browsing to allow it.
Check apache FAQ:

http://httpd.apache.org/docs/misc/FAQ.html
http://httpd.apache.org/docs/misc/FAQ.html#forbidden
http://httpd.apache.org/docs/misc/FAQ.html#malfiles

Please could you post the config portion that has
DocumentRoot directive.

Mine is on Win32, but it should be OK.

DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

2nd part of the quesstion: http://www.website.com/htdocs/index.php should have been http://www.website.com/index.php

Remember that htdocs is a Root for your website (/), anything below that directory would have (/dir1, /dir2), and the url would be http://www.website.com/dir1/, etc.

If you want to have index.php to be your default directory index, ie, you would need to type only http://www.websites.com/ (and not http://www.website.com/index.php), look at DirectoryIndex directive.  By default, I believe it is;

DirectoryIndex index.html

My example; the following would make the default indexfile to be index.cgi if it exist, next index.php, index.html, etc.

DirectoryIndex index.cgi index.php index.html index.htm index.html.var

You would need to have mod_dir (http://httpd.apache.org/docs/mod/mod_dir.html) loaded.

I hope this help.

cheers.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7131532
you simply need in httpd.conf:

  Options Indexes

for / directory
0
 

Author Comment

by:choccarlm
ID: 7137160
Ok,

http://www.website.com/ now works, but if I put in http://www.website.com/htdocs/index.php, it still says that the page doesnt exist. If I put in http://www.website.com/includes/index.php, it works.

For some reason, it will not allow me to use "htdocs/...". Why would this be?

Thanks
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 15

Expert Comment

by:samri
ID: 7137233
Choccarlm,

Yes, you cannot use /htdocs/index.php.

Does it work if you just use http://www.website.com/index.php ?

Remember that /htdocs is just a folder in /usr/local/apache/, and if you notice there is a directive; somewhere in you httpd.conf (or look for that directive).

DocumentRoot /usr/local/apache/htdocs

This is to tell apache, evertyhing in this directory would be treated as the root (/) of your website.  And any path under that folder would be another path in the URL.

cheers.
Samri
0
 

Author Comment

by:choccarlm
ID: 7137254
My Document root for this website is

/home/website/

htdocs is a folder within the webiste folder, so it does exist.

If I put in http://www.website.com/, it now works, as does
http://www.website.com/index.php.

I take it I cannot use htdocs as a folder name then?
0
 
LVL 15

Expert Comment

by:samri
ID: 7137292
M,

Hmm... I cannot recall htdocs being so special.  Could you try to create another directory, maybe testdir and try to test.

Btw, do you have any files under htdocs?  Is it possibble to access the file http://www.domain.com/htdocs/something.html

cheers
0
 

Author Comment

by:choccarlm
ID: 7137302
My Document root for this website is

/home/website/

htdocs is a folder within the webiste folder, so it does exist.

If I put in http://www.website.com/, it now works, as does
http://www.website.com/index.php.

I take it I cannot use htdocs as a folder name then?
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 9691020
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area with the following recommendation for this question:

PAQ/Refund (questions not fully answered)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

periwinkle
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9735863
PAQed, with points refunded (50)

Computer101
E-E Admin
0
 

Expert Comment

by:webwide
ID: 10361378
This question WAS answered!  samri seems to have answered it (IMHO)
0
 
LVL 15

Expert Comment

by:samri
ID: 10401355
I tought that so...  :(
0
 

Expert Comment

by:lisajson
ID: 10774712
Is there any way to have the Web users just type in www.website.com instead of www.website.com/ or www.website.com/index.html?

This seems to work on my apache linux machine, but not on my apache windows 2000 machine.

Thanks for any help you can give me!
Lisa
0
 
LVL 15

Expert Comment

by:samri
ID: 10789965
hi Lisa,

>> Is there any way to have the Web users just type in www.website.com instead of www.website.com/ or www.website.com/index.html?

This is among the popular Apache question.

One common solution is to fix the ServerName directive in you httpd.conf (or in the Vhost Container).  Check Apace FAQ here : http://httpd.apache.org/docs/misc/FAQ.html#set-servername

Another thing is to check for DirectoryIndex directive.  It's covered in mod_dir - http://httpd.apache.org/docs-2.0/mod/mod_dir.html (http://httpd.apache.org/docs-2.0/mod/mod_dir.html#directoryindex).

You may need to add

DirectoryIndex index.html index.htm

Hope this would help.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question