How to place Drupal_Security_Do_Not_Remove_See_SA_* into httpd.conf instead of .htaccess I run several Drupal 7 installations on a dedicated server with CentOS 6.4 and Apache 2 (the package httpd-2.2.15-29.el6.centos.x86_64).

I wonder, how to properly configure the Drupal_Security_Do_Not_Remove_* handlers in my /etc/httpd/conf/httpd.conf file since .htaccess files are disabled at my server by AllowOverride None directive.

Currently I have the following sections in httpd.conf for each of my sites:

&lt;Directory "/var/www/html"&gt;
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;
......
&lt;VirtualHost 123.123.123.123:80&gt;
    DocumentRoot /var/www/html/mysite1.de
    ServerName mysite1.de
    ServerAlias mysite1.de *.mysite1.de

    &lt;IfModule mod_rewrite.c&gt;
        &lt;Directory "/var/www/html/mysite1.de"&gt;
            RewriteEngine on
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} !=/favicon.ico
            RewriteRule ^ index.php [L]
        &lt;/Directory&gt;
    &lt;/IfModule&gt;
&lt;/VirtualHost&gt;


And the recommended settings for the .htaccess are those here:

Options None
Options +FollowSymLinks

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
&lt;Files *&gt;
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
&lt;/Files&gt;

&lt;IfModule mod_php5.c&gt;
  php_flag engine off
&lt;/IfModule&gt;


Should the result in my case be the following?

&lt;Directory "/var/www/html"&gt;
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;
......
&lt;VirtualHost 123.123.123.123:80&gt;
    DocumentRoot /var/www/html/mysite1.de
    ServerName mysite1.de
    ServerAlias mysite1.de *.mysite1.de

    Options None
    Options +FollowSymLinks
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
    &lt;Files /var/www/html/mysite1.de/sites/default/files/*&gt;
        SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
    &lt;/Files&gt;

    &lt;IfModule mod_rewrite.c&gt;
        &lt;Directory "/var/www/html/mysite1.de"&gt;
            RewriteEngine on
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} !=/favicon.ico
            RewriteRule ^ index.php [L]
        &lt;/Directory&gt;

        &lt;Directory "/var/www/html/mysite1.de/sites/default/files"&gt;
            php_flag engine off
        &lt;/Directory&gt;
    &lt;/IfModule&gt;
&lt;/VirtualHost&gt;
.htaccess files are just convienance mechanisms to change Apache configuration without needing to restart Apache (.htaccess are scanned/run any request) -- for performance reasons you may want to place any directives in .htaccess files directly into a vhost entry so the configuration is loaded and stored only one time; on Apache startup.

From the security notice SA-2013-003:


  Warning: Fixing the code execution prevention may require server
  configuration; please read:
  
  To fix the code execution prevention
  vulnerability on existing Apache installations also requires changes
  to your site's .htaccess files in the files directories. Until you do
  this, your site's status report page at admin/reports/status will
  display error messages about the problem. Please note that if you are
  using a different web server such as Nginx the .htaccess files have no
  effect and you need to configure PHP execution protection yourself in
  the respective server configuration files.
  
  To fix this issue, you must edit or replace the old .htaccess files
  manually. Copies of the .htaccess files are found in the public files
  directory and temporary files directory, and (for Drupal 7 only) the
  private files directory if your site is configured to use one.


So you take whatever is in the .htaccess file in your websites configured files directories (public, private, etc) and assure those same rules are in the vhost entry for the same set of directories. Typically you do this with a &lt;Directory&gt; directive:

&lt;Directory "/var/www/html"&gt;
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;
......
&lt;VirtualHost 123.123.123.123:80&gt;
    DocumentRoot /var/www/html/mysite1.de
    ServerName mysite1.de
    ServerAlias mysite1.de *.mysite1.de

    &lt;IfModule mod_rewrite.c&gt;
        &lt;Directory "/var/www/html/mysite1.de"&gt;
            RewriteEngine on
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} !=/favicon.ico
            RewriteRule ^ index.php [L]
        &lt;/Directory&gt;
    &lt;/IfModule&gt;

    # Enforce new security rules from SA-CORE-2013-003.
    # repeat this block as needed per known "files" directories.
    &lt;Directory "/var/www/html/mysite1.de/sites/default/files"&gt;
      # Turn off all options we don't need.
      Options None
      Options +FollowSymLinks

      # Set the catch-all handler to prevent scripts from being executed.
      SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
      &lt;Files *&gt;
        # Override the handler again if we're run later in the evaluation list.
        SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
      &lt;/Files&gt;

      # If we know how to do it safely, disable the PHP engine entirely.
      &lt;IfModule mod_php5.c&gt;
        php_flag engine off
      &lt;/IfModule&gt;
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;


It doesnt matter if the default web directory has AllowOverride None; typically another conf file included down the apache startup chain, or the virtual host loading setup (such as the following in Ubuntu) can be tweaked to allow any combination of Overrides:

# Ubuntu apache2.conf last line ...
# Include the virtual host configurations:
Include sites-enabled/


This is just saying include *.conf from sites-enabled these dont have to be vhost entries they can be any files with apache directives (but its cleanest to have them be vhost entries) and apache loads the configuration files following a filename pattern/sort.