Directory index forbidden by Options directive
The error Directory index forbidden by Options directive is a classic Apache configuration hurdle that appears frequently when deploying legacy PHP applications or dynamic PDF generators to shared hosting environments. It typically surfaces immediately after moving code from localhost to a live server, specifically when the web root directory lacks a valid default file. In your specific scenario involving CodeIgniter and dompdf, this error prevents the application from serving the generated PDF or initializing the controller correctly because Apache refuses to guess which file to load.
The core of the issue lies in how Apache handles requests for directories. When a client visits http://domain.co.uk/invoices/ without specifying a filename (e.g., /invoices/file.pdf), Apache checks your .htaccess or virtual host configuration for an Options directive. By default, the configuration often sets Options Indexes FollowSymLinks. This tells Apache: "If you land on a directory and there is no specific file requested, look for index.html, index.php, or other standard files."
However, modern security best practices have shifted this default to Options -Indexes +FollowSymLinks. The -Indexes flag explicitly forbids the server from listing directory contents. If your application does not define a valid index file within that directory, Apache halts the request and returns a 403 Forbidden error with the message you are seeing. This is distinct from a missing file; it is an active refusal by the server to serve a directory listing.
The suggestion found in various forums to create a blank index.html or index.php file in your document root is technically sound but often misunderstood in practice. Simply placing a file in /var/www/vhosts/domain.co.uk/httpdocs/ (the main root) might not resolve the error if the script triggering the issue resides deep within a subdirectory, such as /mm/userdata/account1/invoices/. Apache evaluates the Options directive relative to the specific request path. If your .htaccess file in that specific invoice directory does not explicitly allow indexing or define an index file, the global setting or inherited settings will still block access.
Since you mentioned lacking access to httpd.conf, you must rely on .htaccess files located within the project's directory structure. To resolve this without root access, you need to add a directive that either re-enables indexing (not recommended for security) or, more appropriately, defines a valid index file so Apache has something to serve instead of listing the folder.
Add the following line to your .htaccess file located in /mm/userdata/account1/invoices/:
DirectoryIndex index.php index.html
This directive tells Apache to look for index.php first, then index.html, when a request targets that directory. If your CodeIgniter application relies on index.php as the entry point, ensuring this file exists in that specific subdirectory is crucial. If you are generating PDFs dynamically, ensure that the route logic correctly redirects the user to a specific file path rather than relying on the browser to guess the URL.
If your application architecture expects a default index but you cannot place one there, another approach is to configure the .htaccess file to redirect requests to a known valid controller:
RewriteEngine On
RewriteRule ^$ /mm/userdata/account1/invoices/index.php [L]
However, be cautious with rewrite rules; they can sometimes mask underlying routing issues. The most robust solution is ensuring the physical index.php file exists in every directory that might be accessed as a root. For dompdf specifically, ensure that the generation process concludes with a redirect to a specific file path (e.g., /invoices/download.pdf) rather than trying to serve the PDF content directly from a directory listing.
If you are managing a Laravel project or a similar modern stack at https://laravelcompany.com, this issue is less common because framework scaffolding usually enforces strict routing that avoids directory roots entirely. However, in legacy CodeIgniter setups, the flexibility comes with the responsibility of manually ensuring default index files exist in every subdirectory your application might inadvertently access.