Created
March 13, 2017 00:19
-
-
Save jrmessias/c1a8d88aa9c22afb5bde6a0c01cbbdbc to your computer and use it in GitHub Desktop.
.htaccess example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Não listar arquivos quando não há index.* | |
Options -Indexes | |
# Seguir links simbólicos | |
Options +FollowSymlinks | |
FileETag MTime Size | |
# Adicionar UTF8 aos arquivos a partir da extensão | |
<filesMatch ".(php|htm|html|css|js|xml)$"> | |
AddDefaultCharset UTF-8 | |
</filesMatch> | |
# Forçar o IE a utilizar o motor mais atual | |
<IfModule mod_headers.c> | |
Header set X-UA-Compatible "IE=Edge,chrome=1" | |
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$"> | |
Header unset X-UA-Compatible | |
</FilesMatch> | |
<FilesMatch "\.(js|css|xml|gz)$"> | |
Header append Vary: Accept-Encoding | |
</FilesMatch> | |
</IfModule> | |
# Comprimir conteúdo com mod_deflate | |
<IfModule mod_deflate.c> | |
SetOutputFilter DEFLATE | |
# Netscape 4.x | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
# Netscape 4.06-4.08 | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
# MSIE mascara como Netscape | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
# Don't compress images | |
SetEnvIfNoCase Request_URI \ | |
\.(?:gif|jpe?g|png)$ no-gzip dont-vary | |
# Certifique-se de que os proxies não fornecem conteúdo errado | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> | |
# Comprimir conteúdo com mod_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_include mime ^application/javascript.* | |
mod_gzip_item_exclude mime ^image\.* | |
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* | |
</IfModule> | |
# Cache de arquivos por 30 dias - Imagens, CSS, JS, SWF, FLV, PDF, ICO | |
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</filesMatch> | |
# Cache de arquivos por 2 dias - XML e TXT | |
<filesMatch "\.(xml|txt)$"> | |
Header set Cache-Control "max-age=172800, public, must-revalidate" | |
</filesMatch> | |
# Cache de arquivos por 2 dias - Fontes | |
<FilesMatch "\.(eot|woff|ttf|svg)$"> | |
Header set Cache-Control "max-age=172800, public, must-revalidate" | |
</FilesMatch> | |
# Cache de arquivos por 2 horas - HTML e HTM | |
<filesMatch "\.(html|htm)$"> | |
Header set Cache-Control "max-age=7200, must-revalidate" | |
</filesMatch> | |
# Permite que o servidor utilize a mesma conexão para transferir múltiplos arquivos | |
<ifModule mod_headers.c> | |
Header set Connection keep-alive | |
</ifModule> | |
# Adicionando mimetypes para vídeos | |
AddType video/ogg .ogv | |
AddType video/mp4 .mp4 | |
AddType video/webm .webm | |
# Forçando download de algumas extensões | |
AddType application/octet-stream .pdf | |
AddType application/octet-stream .doc | |
AddType application/octet-stream .docx | |
AddType application/octet-stream .avi | |
AddType application/octet-stream .mpg | |
AddType application/octet-stream .mpeg | |
AddType application/octet-stream .wmv | |
AddType application/octet-stream .mp3 | |
##### APP | |
# Habilita rewrite | |
RewriteEngine On | |
# Forçar acesso sempre por www | |
#RewriteCond %{HTTP_HOST} !^www\. | |
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
# Acesso sem index.php | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^ index.php [QSA,L] | |
##### SEO | |
# Libwww-perl Access Test | |
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots | |
Deny from env=block_bad_bots | |
# Image Expires Tag Test | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/x-icon "access plus 1 month" | |
ExpiresByType image/gif "access plus 1 month" | |
ExpiresByType image/png "access plus 1 month" | |
ExpiresByType image/jpg "access plus 1 month" | |
ExpiresByType image/jpeg "access plus 1 month" | |
ExpiresByType text/html "access plus 1 month" | |
ExpiresByType text/css "access plus 1 month" | |
ExpiresByType application/javascript "access plus 1 month" | |
ExpiresByType application/vnd.ms-fontobject "access plus 1 month" | |
ExpiresByType application/octet-stream "access plus 1 month" | |
ExpiresByType image/svg+xml "access plus 1 month" | |
ExpiresByType application/font-woff "access plus 1 month" | |
ExpiresByType application/font-woff2 "access plus 1 month" | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment