Enabling .htaccess in Apache for Drupal
Content management systems like Drupal require specific web server directives in order to work properly. The following steps enable Apache to recognize .htaccess files containing those specific web server directives.
The steps outlined here require the use HTTPS for better security on both Debian-based Linux distributions and the FreeBSD operating system.
==========
1. DEBIAN-BASED LINUX DISTRIBUTIONS
1.1. Go to the directory containing the Apache site configuration files.
user@host: $ cd /etc/apache2/sites-available
1.2. BACK UP the default HTTPS configuration file for the secure site.
user@host: $ sudo cp default-ssl.conf default-ssl-conf.back
1.3. Open the default HTTPS configuration file.
user@host: $ sudo nano default-ssl.conf
1.4. Find the "DocumentRoot" section and add the "Directory" block marked "For Drupal" as follows.
# BEGIN CODE
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
# ...
DocumentRoot /var/www/html
#For Drupal
<Directory /var/www/html >
# "Directory" must be the same as "DocumentRoot".
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# "AllowOverride All" ensures that .htaccess works.
Order allow,deny
Allow from all
</Directory>
#For Drupal
# ...
</VirtualHost>
</IfModule>
1.5. Restart the web server.
user@host: $ sudo /etc/init.d/apache2 restart
1.6. Test the Drupal site by accessing HTTPS.
user@host: $ lynx https://localhost
2. FREEBSD OPERATING SYSTEM
2.6. Test the Drupal site by accessing HTTPS.
user@host: $ curl -k https://localhost
==========
# BEGIN CODE
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
# ...
DocumentRoot /var/www/html
#For Drupal
<Directory /var/www/html >
# "Directory" must be the same as "DocumentRoot".
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# "AllowOverride All" ensures that .htaccess works.
Order allow,deny
Allow from all
</Directory>
#For Drupal
# ...
</VirtualHost>
</IfModule>
# END CODE
user@host: $ sudo /etc/init.d/apache2 restart
1.6. Test the Drupal site by accessing HTTPS.
user@host: $ lynx https://localhost
2. FREEBSD OPERATING SYSTEM
2.1. Go to the directory containing the Apache site configuration files.
user@host: $ cd /usr/local/etc/apache24/extra
2.2. BACK UP the default HTTPS configuration file for the secure site.
user@host: $ sudo cp httpd-ssl.conf httpd-ssl-conf.back
2.3. Open the default HTTPS configuration file.
user@host: $ sudo ee httpd-ssl.conf
2.4. Find the "DocumentRoot" section and add the "Directory" block marked "For Drupal" as follows.
# BEGIN CODE
<VirtualHost _default_:443>
# ...
DocumentRoot /usr/local/www/apache24/data
# ...
#For Drupal
<Directory /usr/local/www/apache24/data >
# BEGIN CODE
<VirtualHost _default_:443>
# ...
DocumentRoot /usr/local/www/apache24/data
# ...
#For Drupal
<Directory /usr/local/www/apache24/data >
# "Directory" must be the same as "DocumentRoot".
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# "AllowOverride All" ensures that .htaccess works.
Order allow,deny
Allow from all
</Directory>
#For Drupal
# ...
</VirtualHost>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# "AllowOverride All" ensures that .htaccess works.
Order allow,deny
Allow from all
</Directory>
#For Drupal
# ...
</VirtualHost>
# END CODE
2.5. Restart the web server.
user@host: $ sudo service apache24 restart
user@host: $ sudo service apache24 restart
2.6. Test the Drupal site by accessing HTTPS.
user@host: $ curl -k https://localhost
==========
Comments
Post a Comment