Solved

Directory index forbidden by rule -- Problem

Posted on 2002-07-04
13
64,597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…

756 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