Is it possible to apply the AllowOverride directive globally? (without, therefore, going to every single configuration file and adding the directive)


Yes, directives in a <Directory> container are inherited to child directories. You could set the "global" setting for a parent directory of all your document roots, e.g. /var/www (if your DocumentRoots are /var/www/html, /var/www/example.com etc.).

Example: Modified /var/www in apache.conf (Debian), default is AllowOverride None:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        # commented the default behaviour
        #AllowOverride None

        # new setting, only set the types you need, e.g. AuthConfig, FileInfo etc.
        AllowOverride All
        Require all granted

Of course you have to make sure that there are no other <Directory> directives below this directory which reset the setting to None again.

For fine-tuning which individual directives are allowed in .htaccess files, see the AllowOverrideList directive.

  • (/ and /var/www are the same thing, right?) So, since I have everything in /var/www (folder1 and all subfolders, folders2, etc.), if I set this directive in the configuration file (which I renamed to 000-name.conf to get it launched "first ") and also outside of any VirtualHost, will it be inherited from all other configuration files? (as long as they don't change this directive ... but this doesn't happen) – vincenzogianfelice May 17 '20 at 2:32
  • 1
    / is the root of your filesystem, I wouldn't enable anything for that directory. Set the directive in your main Apache config (apache.conf, httpd.conf) and it's inherited in all your vhosts. If you set it in a vhost, then it's only enabled in that vhost. – Freddy May 17 '20 at 2:45
  • Thanks...is there a way to check if the actual directive function or not? (in the file log apache?) – vincenzogianfelice May 17 '20 at 12:22
  • For most modules you need a more verbose LogLevel (debug or one of the trace levels). But you can enable per-module logging, something like LogLevel info ssl:debug rewrite:trace3 for a general info level, debug for mod_ssl and trace3 for mod_rewrite. – Freddy May 17 '20 at 16:17
  • If AllowOverride is set to None, then .htaccess files are completely ignored. But if you enable one specific type of directives and use a directive that is not enabled (e.g. AuthConfig is enabled and you use RewriteEngine On which needs FileInfo enabled), you'll get an internal server error and the error is logged if you load a page from that directory. There's an option Nonfatal=... you can additionally set to treat those errors as non-fatal (errors are logged, but no HTTP 500 error). – Freddy May 17 '20 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.