Table of Contents


Configuration Files

  • /etc/apache2/httpd.conf - Main apache configuration. Includes module configurations using Include directive.
  • /etc/apache2/modules.d/*.conf - Modules configuration files
  • /etc/apache2/vhosts.d/*.conf - VirtualHosts configuration files


Redirect site to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Redirect all non-domain names to the domain
RewriteEngine On
RewriteCond %{HTTP_HOST} !^
RewriteRule (.*)$1 [R=301,L]
Redirect non-www prefix for a domain to www
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]
Rewrite if REQUEST_URI matches string

You can use Perl regular expression syntax with RewriteCond

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(dmc)?wiki
RewriteRule ^(.*)$$1
Allow access from subnet only
Order Deny,Allow
Deny from all
Allow from
List modules


apachectl -t -D DUMP_MODULES
Disable any caching on 192.168.12. subnet
SetEnvIf Remote_Addr 192\.168\.12\. local
<IfModule mod_headers.c>
Header set Pragma "" env=local
Header set Cache-Control "" env=local
Header set Expires "Sat, 01 Jan 2000 00:00:00 GMT" env=local
Enable PHP overrides in .htaccess

If PHP is installed as a CGI binary, this will not work. But it is safe to set because of IfModule.

<IfModule mod_php5.c>
php_value include_path ".:/usr/local/lib/php"