Table of Contents
Apache
Welcome to the world wide web!
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
Howtos
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} !^www.domain.com RewriteRule (.*) http://www.domain.com$1 [R=301,L]
Redirect non-www prefix for a domain to www
RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$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 ^(.*)$ https://wiki.digitaltrike.com/$1
Allow access from subnet only
Order Deny,Allow Deny from all Allow from 192.168.1.0/24
List modules
CentOS:
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 </IfModule>
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" </IfModule>