Skip to content

Instantly share code, notes, and snippets.

@olimortimer
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olimortimer/b283d270a4ecce9d51f8 to your computer and use it in GitHub Desktop.
Save olimortimer/b283d270a4ecce9d51f8 to your computer and use it in GitHub Desktop.
htaccess snippets
# Force SSL
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Stop browsing of CDN
RewriteCond %{HTTP_HOST} ^cdn\.host\.co\.uk$ [NC]
RewriteCond $1 !\.(css|htc|less|js|js2|js3|js4|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip)$
RewriteRule ^(.*)$ https://www.host.co.uk/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment