Skip to content

Instantly share code, notes, and snippets.

@SecureCloud-biz
Forked from joeworkman/gist:9215120
Last active August 29, 2015 14:23
Show Gist options
  • Save SecureCloud-biz/bf5799c35eea5b67d04b to your computer and use it in GitHub Desktop.
Save SecureCloud-biz/bf5799c35eea5b67d04b to your computer and use it in GitHub Desktop.
# Simple redirect
Redirect 301 /mac/mynest/ http://joeworkman.net/mac/climate/
# 404 Error catch
ErrorDocument 404 /errors/404/index.html
ErrorDocument 403 /errors/404/index.html
ErrorDocument 500 /errors/500/index.html
# Compression
<IfModule mod_deflate.c>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
# Compression with gzip
<IfModule mod_gzip.c>
    mod_gzip_on       Yes
    mod_gzip_dechunk  Yes
    mod_gzip_item_include file      \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler   ^cgi-script$
    mod_gzip_item_include mime      ^text/.*
    mod_gzip_item_include mime      ^application/x-javascript.*
    mod_gzip_item_exclude mime      ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# Disable Directory Access
Options -Indexes
# Expire times for caching
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
# Favicon (cannot be renamed!) and cursor images
ExpiresByType image/x-icon "access plus 1 week"
# HTML components (HTCs)
ExpiresByType text/x-component "access plus 1 month"
# HTML
ExpiresByType text/html "access plus 0 seconds"
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
# MIME Types
AddType font/opentype otf
AddType video/ogg .ogv
AddType video/mp4 .mp4 .m4v
AddType video/webm .webm
AddType video/quicktime .mov
AddType text/x-component .htc
AddType text/cache-manifest .appcache
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# prevent viewing of a specific file
<Files secretfile.jpg>
order allow,deny
deny from all
</Files>
# multiple file types
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>
# Stop people from using images hosted on your domain
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?queness.com/.*$ [NC]
RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
# Redirect to https
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# Skip WWW
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.queness.com [NC]
RewriteRule ^(.*)$ http://queness.com/$1 [L,R=301]
# URL Rewrite
RewriteEngine On
# redirect all /product* to /rapidweaver
RewriteRule ^products.* /rapidweaver [R=301]
# Blog Redirects
RewriteRule blog/index.php/post-([0-9]+) /blog/index.php?id=$1
RewriteRule blog/post-([0-9]+) /blog/index.php?id=$1
RewriteRule blog/page-([0-9]+) /blog/index.php?page=$1
RewriteRule blog/type-([a-zA-Z]+) /blog/index.php?type=$1
RewriteRule blog/tag-(\S+) /blog/index.php?tag=$1
RewriteRule blog/search-(\S+) /blog/index.php?search=$1
RewriteRule blog/refresh /blog/index.php?refresh=1
RewriteRule blog/refresh-all /blog/index.php?refresh=all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment