Skip to content

Instantly share code, notes, and snippets.

@azimidev
Last active June 19, 2016 22:02
Show Gist options
  • Save azimidev/de3455267f2c4eebd94fa21c1cd831cf to your computer and use it in GitHub Desktop.
Save azimidev/de3455267f2c4eebd94fa21c1cd831cf to your computer and use it in GitHub Desktop.
Parsclick htaccess
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
ErrorDocument 400 /400
ErrorDocument 403 /403
ErrorDocument 404 /404
ErrorDocument 500 /500
<IfModule mod_rewrite.c>
IndexIgnore *
Options +FollowSymlinks
Options +SymLinksIfOwnerMatch
Options -Indexes
Options -MultiViews
RewriteEngine On
# RewriteBase /
## TODO: Remove WWW
# RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
## TODO: Force WWW
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NC]
## TODO: To make website Unavailable
# RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif|bmp|js|min|svg|eot|ttf|woff|woff2|otf) [NC]
# RewriteCond %{REQUEST_URI} !unavailable [NC]
# RewriteRule .* /unavailable [R=302,L]
DirectoryIndex index.php index.html
## Remove index from URL TODO try this on server
RewriteCond %{THE_REQUEST} ^.*/index [OR]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index(\.php)?$ /$1 [R=307,L]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L,NC]
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [QSA,L,NC]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
</IfModule>
# BEGIN Expires
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 3 seconds"
ExpiresByType text/html "access plus 3 seconds"
ExpiresByType image/gif "access plus 2419200 seconds"
ExpiresByType image/jpeg "access plus 2419200 seconds"
ExpiresByType image/png "access plus 2419200 seconds"
ExpiresByType text/css "access plus 2419200 seconds"
ExpiresByType text/javascript "access plus 2419200 seconds"
ExpiresByType application/x-javascript "access plus 2419200 seconds"
</ifModule>
# END Expires
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml svg svgz
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-woff
AddOutputFilterByType DEFLATE application/x-font-woff2
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/eot
AddOutputFilterByType DEFLATE font/woff
AddOutputFilterByType DEFLATE font/woff2
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment