Skip to content

Instantly share code, notes, and snippets.

@mohsinrasool
Forked from eveland/.htaccess
Created December 23, 2015 16:41
Show Gist options
  • Save mohsinrasool/3ebc8c0a4a6a310ab2eb to your computer and use it in GitHub Desktop.
Save mohsinrasool/3ebc8c0a4a6a310ab2eb to your computer and use it in GitHub Desktop.

Revisions

  1. @eveland eveland revised this gist Oct 16, 2015. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions .htaccess Security
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # 5G:[WordPress]
    <ifModule mod_rewrite.c>
    RedirectMatch 403 /\$\&
    RedirectMatch 403 (?i)/\&(t|title)=
    RedirectMatch 403 (?i)/\.(bash|git|hg|log|svn|swp|tar)
    RedirectMatch 403 (?i)/(1|contact|i|index1|iprober|phpinfo|phpspy|product|signup|t|test|timthumb|tz|visit|webshell|wp-signup).php
    RedirectMatch 403 (?i)/(author-panel|class|database|manage|phpMyAdmin|register|submit-articles|system|usage|webmaster)/?$
    RedirectMatch 403 (?i)/(=|_mm|cgi|cvs|dbscripts|jsp|rnd|shadow|userfiles)
    </ifModule>
  2. @eveland eveland revised this gist Oct 16, 2015. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions .htaccess Caching
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/x-javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 2 days"
    </IfModule>
    ## EXPIRES CACHING ##
  3. @eveland eveland revised this gist Oct 16, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions .htaccess Vary Encoding
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <IfModule mod_headers.c>
    <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
    </FilesMatch>
    </IfModule>
  4. @eveland eveland revised this gist Oct 16, 2015. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions .htaccess Enable Compression
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <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>
  5. @eveland eveland revised this gist Oct 9, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions .htaccess Block IP
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <Limit GET POST PUT>
    Order Allow,Deny
    Allow from all
    Deny from 111.222.333.444
    </Limit>
  6. @eveland eveland revised this gist Oct 9, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions .htaccess Prevent Hotlinking
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
    RewriteRule \.(gif|jpe?g?|png)$ - [NC,F,L]
    </IfModule>
  7. @eveland eveland revised this gist Oct 9, 2015. 3 changed files with 9 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions .htaccess Block Access to File
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <Files super-secret.pdf>
    Order Allow,Deny
    Deny from all
    </Files>
    4 changes: 4 additions & 0 deletions .htaccess Block Access to File Types
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
    Order Allow,Deny
    Deny from all
    </FilesMatch>
    1 change: 1 addition & 0 deletions .htaccess Disable Directory Browsing
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Options -Indexes
  8. @eveland eveland revised this gist Oct 9, 2015. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions .htaccess Basic Wordpress
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  9. @eveland eveland revised this gist Oct 9, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #Require SSL
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  10. @eveland eveland renamed this gist Oct 9, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. @eveland eveland created this gist Oct 9, 2015.
    4 changes: 4 additions & 0 deletions .htaccess Require SSL
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>