#> https://www.askapache.com/htaccess/ <#
##############################################
# DEFAULT SETTINGS #
##############################################
Options +All +ExecCGI -Indexes
DirectoryIndex index.html index.php /index.php
### MEDIA TYPES ###
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType application/octet-stream .chm .bz2
AddType application/vnd.ms-excel .csv
AddType application/x-pilot .prc .pdb
AddType application/x-gzip .gz
AddType image/x-icon .ico
### CHARSET LANG ###
DefaultType text/html
AddDefaultCharset utf-8
AddLanguage en-us .html .htm .php .xml
### SETUP ENV ###
SetEnv TZ America/Las_Vegas
SetEnv SERVER_ADMIN webmaster@site.com
ServerSignature off
### ERRORDOCUMENTS ###
ErrorDocument 206 /ERROR/206.html
ErrorDocument 401 /ERROR/401.html
ErrorDocument 403 /ERROR/403.html
ErrorDocument 404 /ERROR/404.html
ErrorDocument 500 /ERROR/500.html
##############################################
# HEADERS and CACHING #
##############################################
#### CACHING ####
ExpiresActive On
ExpiresDefault A3600
# 1 MONTH
ExpiresDefault A2419200
Header append Cache-Control "public"
# 2 HOURS
ExpiresDefault A7200
Header append Cache-Control "private, must-revalidate"
# NEVER CACHE
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
##############################################
# MOD_ALIAS REDIRECTS #
##############################################
#### PERMANENT REDIRECTS ####
Redirect 301 /all.html https://www.askapache.com/htaccess/
Redirect 301 /awkl https://www.askapache.com/awk/awk-tutorial/
Redirect 301 /ben.html https://www.askapache.com/wordpress/best-adsense-optimization/
Redirect 301 /commonly-s.html https://www.askapache.com/htaccess/commonly-used-htaccess-code-examples/
Redirect 301 /css-backgro https://www.askapache.com/css/css-background-image-sprite/
Redirect 301 /htacce https://www.askapache.com/htaccess/feedsmith-htaccess/
### PERMANENT REDIRECTMATCH ###
RedirectMatch 301 ^/([\(]+)(.*)$ https://www.askapache.com/
RedirectMatch 301 ^/(.+)\.htm$ https://www.askapache.com/$1/
RedirectMatch 301 ^/(.+)\.html/$ https://www.askapache.com/$1/
RedirectMatch 301 ^/(.+)/\.html$ https://www.askapache.com/$1/
RedirectMatch 301 ^/&(.*)$ https://www.askapache.com/
#### TEMPORARY REDIRECTS ####
Redirect 307 /about/feeds/ http://feeds.askapache.com/apache/htaccess
Redirect 307 /about/feeds/it/ http://feeds.askapache.com/apache/htaccess
Redirect 307 /apachesearch/ http://google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i
Redirect 307 /apachecsetest/ http://google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i
#### TEMPORARY REDIRECTMATCH ####
RedirectMatch 307 ^/(.*)//(.*)$ https://www.askapache.com/$1/$2
RedirectMatch 307 ^//(.*)$ https://www.askapache.com/$1
RedirectMatch 307 ^/(.*)askapache(.*)askapache(.*)$ https://www.askapache.com/
##############################################
# MOD_REWRITE REWRITES #
##############################################
RewriteEngine On
RewriteBase /
### REQUIRE WWW ###
RewriteCond %{HTTP_HOST} !^www\.site\.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
### CACHEABLE FILES
RewriteRule ^z/j/site-([0-9]+)\.js$ /z/j/site.js [L]
RewriteRule ^z/c/site-([0-9]+)\.css$ /z/c/site.css [L]
##############################################
# MOD_SETENVIF VARIABLES #
##############################################
SetEnvIfNoCase Remote_Host "(.*)" ASKAPACHE_HOST=$1
SetEnvIfNoCase Remote_Addr "(.*)" ASKAPACHE_REMOTE_ADDR=$1
SetEnvIfNoCase Server_Addr "(.*)" ASKAPACHE_SERVER_ADDR=$1
SetEnvIf Request_Method "(.*)" ASKAPACHE_REQUEST_METHOD=$1
SetEnvIf Request_Protocol "(.*)" ASKAPACHE_REQUEST_PROTOCOL=$1
SetEnvIf Request_URI "(.*)" ASKAPACHE_REQUEST_URI=$1
SetEnvIf Remote_Addr 208\.113\.183\.103 REMOTE_HOST=www.askapache.com
#> https://www.askapache.com/htaccess/ <#