I have setup a local VM using Puphpet. My file structure is as follows:
|-www
|- public
-.htaccess
- index.php
| -subdomain
-.htaccess
- index.php
Here are the relevant bits from my config.yaml:
modules:
- rewrite
vhosts:
fj3ju1mwry6l:
servername: main.dev
serveraliases:
- www.main.dev
docroot: /var/www/public
port: '80'
setenv:
- 'APP_ENV dev'
directories:
zfy5qmype3xj:
provider: directory
path: /var/www/public
options:
- Indexes
- FollowSymlinks
- MultiViews
allow_override:
- All
require:
- all
- granted
custom_fragment: ''
engine: php
3xbo0zhpbo5g:
servername: subdomain.main.dev
docroot: /var/www/subdomain
port: '80'
directories:
otngayglj5ug:
provider: directory
path: ''
options:
- Indexes
- FollowSymlinks
- MultiViews
allow_override:
- All
require:
- all
- granted
custom_fragment: ''
engine: php
custom_fragment: ''
mod_pagespeed: 0
In each .htaccess I have placed:
deny from all
Visiting main.dev results in forbidden which is correct, however, visiting subdomain.main.dev displays the index.php. Anybody know the .htaccess is being ignored by the second vhost?
Ok so incase anybody else experiences the same thing. The second vhosts conf file (found at /etc/httpd/conf.d/xxxx.conf) did not have anything declared under Directories (I assume there must be a bug with Puphpet or Vagrant). I added the following (taken from the first vhosts conf):
<Directory "/var/www/school">
Options Indexed FollowSymlinks MultiViews
AllowOverride All
Require all granted
</Directory>
And now both htaccess files are being picked up.
EDIT
Ok, so after all that I noticed this line in my config yaml (path):
otngayglj5ug:
provider: directory
path: ''
options:
After filling that in and re-provisioning it worked as expected.