I'm using the dompdf plugin for codeigniter: http://codeigniter.com/wiki/PDF_generation_using_dompdf/
to generate pdfs from a form. This works on localhost, but on the live server I get this in the error log:
Directory index forbidden by Options directive: /var/www/vhosts/domain.co.uk/httpdocs/mm/userdata/account1/invoices/
Any idea what this means? I've searched for answers, and found a few that suggest editing the httpd.conf, however I don't have access to this.
I've also tried adding a blank index.html file to the root and document directory (as also suggested elsewhere, but to no avail).
Any help greatly appreciated.
Thanks!
The Problem
Indexes visible in a web browser for directories that do not contain an index.html or index.php file.
I had a lot of trouble with the configuration on Scientific Linux's httpd web server to stop showing these indexes.
The Configuration that did not work
httpd.conf virtual host directory directives:
and the addition of the following line to .htaccess:
Directory indexes were still showing up. .htaccess settings weren't working!
How could that be, other settings in .htaccess were working, so why not this one? What's going? It should be working! %#$&^$%@# !!
The Fix
Change httpd.conf's Options line to:
and restart the webserver.
Voilà directory indexes were no longer showing up for directories that did not contain an index.html or index.php file.
Now What! A New Wrinkle
New entries started to show up in the 'error_log' when such a directory access was attempted:
This entry is from the Apache module 'autoindex' with a LogLevel of 'error' as indicated by [autoindex:error] of the error message---the format is [module_name:loglevel].
To stop these new entries from being logged, the LogLevel needs to be changed to a higher level (e.g. 'crit') to log fewer---only more serious error messages.
Apache 2.4 LogLevels
See Apache 2.4's core directives for LogLevel.
emerg, alert, crit, error, warn, notice, info, debug, trace1, trace2, trace3, tracr4, trace5, trace6, trace7, trace8
Each level deeper into the list logs all the messages of any previous level(s).
Apache 2.4's default level is 'warn'. Therefore, all messages classified as emerg, alert, crit, error, and warn are written to error_log.
Additional Fix to Stop New error_log Entries
Added the following line inside the <Directory>..</Directory> section of httpd.conf:
The Solution 1
My virtual host's httpd.conf <Directory>..</Directory> configuration:
and adding to /home/mydomain.com/htdocs/.htaccess, the root directory of your website's .htaccess file:
If you don't mind the 'error' level messages, omit
Scientific Linux - Solution 2 - Disables mod_autoindex
No more autoindex'ing of directories inside your web space. No changes to .htaccess. But, need access to the httpd configuration files in /etc/httpd
Edit /etc/httpd/conf.modules.d/00-base.conf and comment the line:
by adding a # in front of it then save the file.
In the directory /etc/httpd/conf.d rename (mv)
Restart httpd:
or
The autoindex_mod is now disabled.
Linux distros with ap2dismod/ap2enmod Commands
Disable autoindex module enter the command
to enable autoindex module enter
In my case, it's a typo caused this issue:
should be
It means there's no default document in that directory (index.html, index.php, etc...). On most webservers, that would mean it would show a listing of the directory's contents. But showing that directory is forbidden by server configuration (
Options -Indexes
)I got stuck on the same error, the problem was coming from a syntax error in a MySql statement in my code, in particular my $_session variable was missing a "'. It took hours to figure it out because on the error log the statement was misleading. Hope it helps somebody.
Another issue that you might run into if you're running RHEL (I ran into it) is that there is a default welcome page configured with the httpd package that will override your settings, even if you put Options Indexes. The file is in /etc/httpd/conf.d/welcome.conf. See the following link for more info: http://wpapi.com/solved-issue-directory-index-forbidden-by-options-directive/
Insert this lines:
In your
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf
file. I assume you are using Virtual Host for development.And then, of course, just restart Apache.
Documentation