How to fix "the .htaccess file does not work" message


#1

Problem:
One of the following message is showing up during setup or within your admin control panel:

[quote]Your data directory and files are probably accessible from the internet because the .htaccess file does not work.
For information how to properly configure your server, please see the documentation.[/quote]

[quote]Ihr Datenverzeichnis und Ihre Dateien sind wahrscheinlich vom Internet aus erreichbar, weil die .htaccess-Datei nicht funktioniert.
Bitte lesen Sie die Dokumentation, um zu erfahren, wie Sie Ihren Server richtig konfigurieren können.[/quote]

Solution:
A generic solution is to move your data directory out of the web accessible directory like described in the documentation:

https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/harden_server.html#place-data-directory-outside-of-the-web-root

If you don’t want to move your data directory first make sure that no:

/var/www/owncloud/data/htaccesstest.txt (replace the path with your current path)

exists which could fail this test.

Apache
First make sure that the .htaccess file located at:

/var/www/owncloud/data/.htaccess (or the location where you have installed ownCloud)

exists, is readable by the user running your webserver (mostly www-data) and contains the following:

deny from all
IndexIgnore *

The second step is to configure your webserver to parse .htaccess files. This can be achieved with the config directive “AllowOverride All” in your vhost configuration (If there is already an “AllowOverride None” configured you need to replace it).

On various distros you need to edit the /etc/apache2/apache2.conf directly and replace the “AllowOverride None” with “AllowOverride All”.

After doing this step please make sure that you restart your Webserver!!!

An example of such a vhost configuration is provided in the official documentation located here:

http://doc.owncloud.org/server/6.0/admin_manual/installation/installation_source.html#web-server-configuration

NginX
When using NginX you need to make sure that you’re running the config provided at the official documentation:

http://doc.owncloud.org/server/6.0/admin_manual/installation/installation_source.html#nginx-configuration

Especially this part of the config is needed to protect your data directory:

        location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
                deny all;
        }

Lighttpd
No idea, infos are welcome.


Newbie error - data directory maybe visible
Security Message
#2