4

I'm working on Ubuntu 14.04.2 Apache 2.4.7

I have a Virtual host set up to serve files from /var/www/dev and the config file looks like this for dev.conf:

<VirtualHost *:80>
    ServerAdmin ubuntu@12.234.567.89
    DocumentRoot /var/www/dev
    ServerName dev.site.com

    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/dev/>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
</VirtualHost>

I have a number of files in the /var/www/dev directory that I don't want indexed hence the -Indexes option

However I have a wordpress installation here too and I want those files to be served into a browser properly. The index file is index.php and is located in /var/www/dev/

I also have an .htaccess file in this same document root that looks like this:

DirectoryIndex index.php index.html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch 301 ^/terms-and-conditions\.php$ /terms-of-use
RedirectMatch 301 ^/privacy\.php$ /privacy-policy
</IfModule>

The DirectoryIndex should tell the browser to use the index.php file, but I am getting a 403 Forbidden error.

I've tried:

  • Opening up permissions, recursively changing ownership of /var/www/dev to www-data:www-data
  • Adding DirectoryIndex index.php to the dev.conf file within the <Directory /var/www/dev/> tag - above and below the Options item
  • Checking mod_dir is active (it is)
  • Changing the indexes option back to +Indexes - when I load my site it displays the physical file index
  • refreshing browser when I'm given the 403 or directory index will load my page correctly
  • Clearing the browser cache every time I test in the browser
  • Looked in my apache2.conf file and can confirm there is no other reference to DirectoryIndex
  • Removing all references to DirectoryIndex and changing option to +Indexes - this makes everything work OK except users can see the directory index for all folders including the ones I don't want them to access

Any help is much appreciated!

EDIT: Using chrome and firefox dev tools - if I click the option for Disable Cache (when dev tools are open) - the site loads fine - perhaps this is a clue

EDIT 2: error.log outputs this line-

AH01276: Cannot serve directory /var/www/dev/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

access.log just shows my browser details -

"GET / HTTP/1.1" 200 1462 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0"
contool
  • 941
  • 2
  • 15
  • 26

0 Answers0