5

I have a directory structure like the following for a website on Ubuntu 14.04, running apache 2.4.7:

/websites/mywebsite/index.htm
/websites/mywebsite/private.htm
/websites/myqwbsite/folder/privatefile.ext
/websites/mywebsite/folder/subfolder/publicfile.ext

In the Apache config for the site, I have

<Directory /websites/mywebsite/>
   AllowOverride Limit
   Require all granted
</Directory>

I want to use .htaccess files in the site folder such that the private.htm and privatefile.ext files are Require all denied but everything else is granted.

I tried the following two .htaccess files:

/websites/mywebsite/.htaccess:

<FilesMatch (private.*.htm)$>
   Require all denied
</FilesMatch>

/websites/mywebsite/folder/.htaccess:

Require all denied

/websites/mywebsite/folder/subfolder/.htaccess:

Require all granted

However, apache gives a 500 - "Require not allowed here" for /websites/mywebsite/.htaccess

How can I make what I want happen with apache 2.4-compatible configuration (ie I do not want to load mod_access_compat and use the old style config)?

1
  • I also did a test with only the .htaccess file in /websites/mywebsite/folder/subfolder/. All other .htaccess files were removed. Apache still claims "Require not allowed here", even though apache documentation explicitly says it is allowed there: httpd.apache.org/docs/current/mod/mod_authz_core.html#require Commented Jul 26, 2014 at 1:37

1 Answer 1

8

In the apache config for the site, you have to extend AllowOverride properties. Add: FileInfo and AuthConfig. Or set "AllowOverride All"

I had same problem, fixed with this config :

<Directory /websites/mywebsite/>
   Options +FollowSymLinks +SymLinksIfOwnerMatch
   AllowOverride FileInfo AuthConfig
</Directory>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.