TOTAL DE SNIPPETS
87 Códigos
SNIPPETS & DIRETIVAS DE PRODUÇÃO
Catálogo de Códigos & Hardening WordPress
Biblioteca técnica completa com 87 códigos e diretivas prontas para uso em produção divididos em Actions, Filters, diretivas de .htaccess e Shortcodes.
Otimize, proteja e customize suas instâncias diretamente no functions.php, mu-plugins ou .htaccess, eliminando o overhead de plugins pesados e reduzindo a superfície de ataque.
CATEGORIAS
4 Áreas TécnicasINTEGRAÇÃO SECOPS
100% Client-SideBIBLIOTECA TÉCNICA
Snippets Prontos para Uso em Produção
Filtre por categoria ou pesquise em tempo real. Clique em Copiar para obter o trecho limpo ou compartilhe links diretos utilizando o botão #.
Exibindo 87 de 87 snippets
WordPress - Remove emojis
add_action('init', fn() => {
remove_action('wp_head', 'print_emoji_detection_script', 10);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
});
WordPress - Altere a URL de base do autor exemplo /escritor/teste
function wp_custom_author_urlbase($wp_rewrite) {
$author_slug = 'NOVO_VALOR'; // the new slug name
$wp_rewrite->author_base = $author_slug;
$wp_rewrite->flush_rules(); // Use flush_rules() instead of flush_rewrite_rules()
}
add_action('init', 'wp_custom_author_urlbase');
WordPress - Altera a string de pesquisa padrão '?s=' para outro valor
add_action('init', fn() => {
add_rewrite_tag('%search_query%', '([^&]+)');
remove_query_arg('s');
});
add_filter('request', fn($request) => {
if (isset($request['search_query'])) {
$search_query = sanitize_text_field($request['search_query']);
$request['NOVO_VALOR'] = $search_query;
}
return $request;
});
WordPress - Desabilita a busca padrão
add_action('init', fn() => {
add_rewrite_tag('%search_query%', '([^&]+)');
remove_query_arg('s');
});
add_filter('request', fn($request) => {
if (isset($_GET['search'])) {
$search_query = sanitize_text_field($_GET['search']);
$request['s'] = $search_query;
}
return $request;
});
WordPress - Remove a versão do WordPress do cabeçalho
add_action('init', fn() => {
remove_action('wp_head', 'wp_generator');
});
WordPress - Desabilita o FontAwesome
add_action('wp_enqueue_scripts', fn() => wp_dequeue_style('font-awesome'), 50);
WordPress - Habilita o RSS no cabeçalho
add_theme_support('automatic-feed-links');
WordPress - Esconde o admin-ajax de usuários não autenticados
add_action('admin_init', fn() => {
if (!current_user_can('manage_options') && !is_admin()) {
wp_redirect(home_url());
exit;
}
});
WordPress - Altera o texto do rodapé no backend
add_action('admin_footer_text', fn() => echo 'YOUR NEW FOOTER';);
WordPress - Previne o upload de arquivos para usuários que não são da equipe
function pws_block_admin() {
$request_uri = $_SERVER['REQUEST_URI'];
if (
stripos($request_uri, '/wp-admin/') !== false &&
stripos($request_uri, 'async-upload.php') === false &&
stripos($request_uri, 'admin-ajax.php') === false &&
!current_user_can('manage_options')
) {
wp_safe_redirect(home_url(), 302);
exit;
}
}
add_action('admin_init', 'pws_block_admin', 0);
WordPress - Move o jQuery jQueryMigrate para o rodapé
add_action('wp_enqueue_scripts', fn() => {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_deregister_script('jquery-migrate');
}
});
function include_jquery_in_footer() {
if (!is_admin()) {
wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-3.6.0.min.js', array(), '3.6.0', true);
wp_enqueue_script('jquery-migrate', 'https://code.jquery.com/jquery-migrate-3.3.2.min.js', array('jquery'), '3.3.2', true);
}
}
add_action('wp_enqueue_scripts', 'include_jquery_in_footer');
WordPress - Adiciona scripts js e css externos
function add_scripts() {
// Enqueue JavaScript
wp_enqueue_script('example-js', 'https://exemplo.com/js/example.js', array(), '1.0', true);
// Enqueue CSS styles
wp_enqueue_style('example-css', 'https://exemplo.com/css/example.css', array(), '1.0');
}
add_action('wp_enqueue_scripts', 'add_scripts');
WordPress - Insere tags personalizadas no corpo
add_action('wp_footer', fn() => {
// Insira aqui o código que você deseja, Google Ads, Analytics, etc
});
Elementor - Remove requisições http para o fontawessome no elementor
add_action('elementor/frontend/after_enqueue_styles', fn() => wp_dequeue_style('font-awesome'));
add_action('elementor/frontend/after_register_styles', fn() => {
foreach (['solid', 'regular', 'brands'] as $style) {
wp_deregister_style('elementor-icons-fa-' . $style);
}
}, 20);
Elementor - Remove eicons no elementor
add_action('wp_enqueue_scripts', fn() => {
wp_dequeue_style('elementor-icons');
wp_deregister_style('elementor-icons');
}, 11);
Elementor - Remove animações do elementor
add_action('wp_enqueue_scripts', fn() => {
wp_deregister_style('elementor-animations');
wp_dequeue_style('elementor-animations');
wp_dequeue_style('elementor-frontend');
}, 100);
WordPress - Remove o CSS padrão do Gutenberg (wp-block-library)
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('wc-blocks-style'); // caso utilize WooCommerce
}, 100);
WordPress - Habilita shortcode no menu
/* Updated to avoid unfiltered_html in menu */
/**
* Custom Walker class to handle shortcodes in navigation menu items.
*/
class Custom_Nav_Menu_Walker extends Walker_Nav_Menu {
/**
* Filter the menu item's content.
*
* @param string $item_output The menu item's starting HTML output.
* @param object $item The current menu item.
* @param int $depth Depth of menu item. Used for padding.
* @param object $args An object of wp_nav_menu() arguments.
* @return string Modified menu item's output.
*/
public function start_el(&$item_output, $item, $depth = 0, $args = null) {
// Execute shortcodes only on the menu item's title (label).
$item_output = do_shortcode($item->title);
parent::start_el($item_output, $item, $depth, $args);
}
}
// Hook the custom walker to 'wp_nav_menu'.
add_filter('wp_nav_menu_args', function($args) {
$args['walker'] = new Custom_Nav_Menu_Walker();
return $args;
});
WordPress - Habilita desconectar do site com uma url mascarada passando string, exemplo /SAIR=1
// Custom logout URL filter.
add_filter('logout_url', fn($logout_url, $redirect) => (
$redirect ? add_query_arg('redirect', esc_url_raw($redirect), wp_logout_url(home_url())) : wp_logout_url(home_url())
), 10, 2);
// Custom logout action on 'wp_loaded'.
add_action('wp_loaded', fn() => custom_logout_action());
WordPress - URL de desconectar personalizada
/**
* Customize the logout URL with additional query parameters.
*
* @param string $logout_url The default logout URL.
* @param string $redirect The URL to redirect to after logout (optional).
* @return string The modified logout URL.
*/
function custom_logout_url($logout_url, $redirect) {
// Generate the logout URL with the 'NEW_VALUE' query parameter
$logout_url = add_query_arg('NEW_VALUE', 1, wp_logout_url(home_url())); // example: bye
// Add the 'redirect' query parameter if provided
if (!empty($redirect)) {
$logout_url = add_query_arg('redirect', esc_url_raw($redirect), $logout_url);
}
return esc_url($logout_url);
}
// Hook the function to the 'logout_url' filter with a priority of 10 and 2 accepted arguments.
add_filter('logout_url', 'custom_logout_url', 10, 2);
WordPress - Ação de desconectar personalizada baseada em um parâmetro
/**
* Custom logout action based on a query parameter.
*/
function custom_logout_action() {
// Check if the 'logout_param' query parameter is set
$logout_param = filter_input(INPUT_GET, 'logout_param', FILTER_SANITIZE_STRING);
if (isset($logout_param)) {
// Perform user logout
wp_logout();
// Get the redirect URL from 'redirect' query parameter, or use home_url() as default
$redirect = filter_input(INPUT_GET, 'redirect', FILTER_SANITIZE_URL);
$loc = isset($redirect) ? $redirect : home_url();
// Redirect the user with a 302 status code (temporary redirect)
wp_redirect(esc_url($loc), 302);
exit;
}
}
// Hook the function to the 'template_redirect' action.
add_action('template_redirect', 'custom_logout_action');
WordPress - Remove a validação do AMP
add_filter(
'amp_validation_error_sanitized',
fn($sanitized, $error) => ($error['node_name'] === 'script' && strpos($error['text'], 'WFAJAXWatcherVars') !== false) ?? $sanitized,
10,
2
);
WordPress - Exibe somente os arquivos enviados pelo próprio usuário na biblioteca
/**
* Show only current user's attachments in the media library via AJAX.
*
* @param array $query The original query arguments.
* @return array Modified query arguments.
*/
function wpsnippet_show_current_user_attachments($query) {
$user_id = get_current_user_id();
if ($user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts')) {
$query['author'] = $user_id;
}
return $query;
}
// Hook the function to the 'ajax_query_attachments_args' filter.
add_filter('ajax_query_attachments_args', 'wpsnippet_show_current_user_attachments');
WordPress - Remove o parâmetro de versão na URL de arquivos js e css
/**
* Remove version parameter from CSS and JS file URLs.
*
* @param string $src The URL of the file.
* @return string The modified URL without the version parameter.
*/
function my_remove_wp_ver_css_js($src) {
if (strpos($src, 'ver=')) {
$src = preg_replace('/\?ver=[^&]+/', '', $src);
}
return $src;
}
// Hook the function to both 'style_loader_src' and 'script_loader_src' filters with a priority of 9999.
add_filter('style_loader_src', 'my_remove_wp_ver_css_js', 9999);
add_filter('script_loader_src', 'my_remove_wp_ver_css_js', 9999);
WordPress - Remove a versão do WordPress
add_filter('the_generator', fn() => '');
WordPress - Remove a barra administrativa
add_filter('show_admin_bar', fn() => false);
WordPress - Desabilita o Gutemberg
add_filter('use_block_editor_for_post', fn() => false);
WordPress - Realiza uma limpeza painel do backend
final class RemoveTrashWP {
public function __construct() {
// Admin Bar
add_action('admin_bar_menu', [$this, 'removeAdminBarItems'], 999);
// Admin Dashboard
add_action('wp_dashboard_setup', [$this, 'cleanAdminDashboard']);
// Admin Head
add_action('wp_loaded', [$this, 'cleanAdminHead']);
// Body Class
add_filter('body_class', [$this, 'addSlugToBodyClass']);
// Contextual Help
add_filter('contextual_help', [$this, 'removeContextualHelp'], 999, 3);
// Widgets
add_action('widgets_init', [$this, 'removeDefaultWidgets']);
// Headers
add_filter('wp_headers', [$this, 'removePingbackHeader']);
add_filter('wp_headers', [$this, 'removeJsonApi']);
// Login URL
add_action('login_headerurl', [$this, 'modifyLoginHeaderURL']);
// Miscellaneous
add_filter('admin_footer_text', '__return_null');
add_filter('emoji_svg_url', '__return_false');
add_filter('enable_post_by_email_configuration', '__return_false', 999);
add_filter('feed_links_show_comments_feed', '__return_false');
add_filter('get_image_tag_class', [$this, 'addImageAlignClass'], 10, 4);
add_filter('jpeg_quality', [$this, 'setJpegQuality']);
add_filter('the_generator', '__return_empty_string');
// Welcome Panel
remove_action('welcome_panel', 'wp_welcome_panel');
}
// Methods for each action/filter (Add comments to describe each one)...
// Admin Bar
public function removeAdminBarItems() {
// Code to remove items from admin bar...
}
// Admin Dashboard
public function cleanAdminDashboard() {
// Code to clean up the admin dashboard...
}
// Admin Head
public function cleanAdminHead() {
// Code to clean up the admin head...
}
// Other methods...
}
WordPress - Habilita o envio do formato WEBP
add_filter('mime_types', fn($mimes) => [
'webp' => 'image/webp',
] + $mimes );
WordPress - Verifica se uma imagem webp está sendo exibida
/**
* Check if a WebP image is displayable.
*
* @param bool $result The default result of whether the image is displayable.
* @param string $path The path to the image file.
* @return bool The updated result of whether the image is displayable.
*/
function webp_is_displayable($result, $path) {
if ($result === false) {
$info = getimagesize($path);
$displayable_image_types = array(IMAGETYPE_WEBP);
$result = ( $info !== false && in_array($info[2], $displayable_image_types) );
}
return $result;
}
// Hook the function to the 'file_is_displayable_image' filter with a priority of 10 and 2 accepted arguments.
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);
WordPress - Remove segmento '/category/' de posts que não são únicos
/**
* Remove the "/category/" segment from non-single post type URLs.
*
* @param string $string The URL to be modified.
* @param string $type The post type.
* @return string Modified URL.
*/
function remove_category_from_url($string, $type) {
if ($type !== 'single' && $type === 'category' && strpos($string, 'category') !== false) {
$url_without_category = str_replace('/category/', '/', $string);
return trailingslashit($url_without_category);
}
return $string;
}
// Hook the function to the 'user_trailingslashit' filter with a priority of 100 and 2 accepted arguments.
add_filter('user_trailingslashit', 'remove_category_from_url', 100, 2);
WordPress - Força o login somente via email
function email_login_authenticate( $user, $username, $password ) {
if ( is_email( $username ) ) {
$user = get_user_by( 'email', $username );
if ( $user ) {
$username = $user->user_login;
}
}
return wp_authenticate_username_password( null, $username, $password );
}
add_filter( 'authenticate', 'email_login_authenticate', 20, 3 );
function email_login_username_label( $translated_text, $text, $domain ) {
if ( $text === 'Username' ) {
$translated_text = 'Email'; // Change 'Username' to 'Email' in the login form.
}
return $translated_text;
}
add_filter( 'gettext', 'email_login_username_label', 20, 3 );
WordPress - Personaliza a barra administrativa para usuários não-administratvos
/**
* Customize the WordPress admin bar for non-administrator users.
*
* @param WP_Admin_Bar $admin_bar The WordPress admin bar object.
* @return WP_Admin_Bar Modified WordPress admin bar object.
*/
function customize_admin_bar_for_non_admins($admin_bar) {
// Check if the current user is not an administrator
if (!current_user_can('administrator')) {
$redirect = site_url();
// Remove unwanted admin bar menus
$admin_bar->remove_menu('wp-logo');
$admin_bar->remove_node('new-content');
$admin_bar->remove_menu('edit');
$admin_bar->remove_menu('updates');
$admin_bar->remove_menu('search');
$admin_bar->remove_menu('comments');
$admin_bar->remove_node('site-name');
$admin_bar->remove_node('my-account');
// Add appropriate login/logout link based on user login status
$login_logout_title = is_user_logged_in() ? 'Sair para Home' : 'Faça Login';
$login_logout_id = is_user_logged_in() ? 'logout' : 'login';
$login_logout_class = is_user_logged_in() ? 'link-logout' : 'link-login';
$login_logout_href = is_user_logged_in() ? wp_logout_url($redirect) : wp_login_url($redirect);
$admin_bar->add_menu(array(
'id' => $login_logout_id,
'parent' => 'top-secondary',
'title' => $login_logout_title,
'href' => $login_logout_href,
'meta' => array('class' => $login_logout_class),
));
}
return $admin_bar;
}
// Hook the function to the 'admin_bar_menu' action with a priority of 999999
add_action('admin_bar_menu', 'customize_admin_bar_for_non_admins', 999999);
WordPress - Protege a pagina de login de ataques de força bruta
// Block direct access to the plugin file
defined('ABSPATH') or die('No script kiddies please!');
// Hook into the login form to add login protection
add_action('login_init', 'custom_login_security');
function custom_login_security() {
// Set the maximum number of login attempts allowed
$max_attempts = 5;
// Set the duration (in seconds) to lock out login attempts
$lockout_duration = 600; // 10 minutes
// Get the user's IP address
$user_ip = $_SERVER['REMOTE_ADDR'];
// Check if the user has exceeded the maximum number of login attempts
$login_attempts = get_transient('custom_login_attempts_' . $user_ip);
if ($login_attempts >= $max_attempts) {
// User has exceeded the maximum login attempts, block further attempts
header('HTTP/1.1 403 Forbidden');
die('Too many login attempts. Please try again later.');
}
}
// Hook into the authentication process to count login attempts
add_filter('wp_authenticate_user', 'custom_track_login_attempts', 10, 2);
function custom_track_login_attempts($user, $username) {
// Get the user's IP address
$user_ip = $_SERVER['REMOTE_ADDR'];
// Get the current login attempts count
$login_attempts = get_transient('custom_login_attempts_' . $user_ip);
// Increase the login attempts count
$login_attempts = ($login_attempts) ? $login_attempts + 1 : 1;
// Save the new login attempts count with a lockout duration
set_transient('custom_login_attempts_' . $user_ip, $login_attempts, $lockout_duration);
return $user;
}
WordPress - Altera a mensagem de erro de login
function error_msgs() {
$custom_error_msgs = [
'<strong>YOU</strong> SHALL NOT PASS!',
'<strong>HEY!</strong> GET OUT OF HERE!',
];
// Return a random error message from the array or use a default message if the array is empty
return !empty($custom_error_msgs) ? $custom_error_msgs[array_rand($custom_error_msgs)] : 'Invalid credentials. Please try again.';
}
add_filter('login_errors', 'error_msgs');
WordPress - Desabilita a RestAPI
add_filter('rest_authentication_errors', function ($access) {
return new WP_Error('rest_api_disabled', __('The REST API is disabled on this site.'), array('status' => 403));
});
Elementor - Remove as fontes do Google
add_filter('elementor/frontend/print_google_fonts', fn() => false);
Rankmath - Adiciona url personalizada no sitemap
add_filter('rank_math/sitemap/xml_img_src', function($src, $post) {
return set_url_scheme($src, 'https');
}, 10, 2);
Rankmath - Remove os créditos do sitemap
add_filter('rank_math/sitemap/remove_credit', fn() => true);
Woocommerce - Altera os links de menu
add_filter('woocommerce_account_menu_items', fn($menu_links) => [
'rastrear-pedido' => 'Rastrear Pedido',
] + $menu_links);
Woocommerce - Altera a variação de produtos no frontend
add_filter('woocommerce_ajax_variation_threshold', fn() => 100);
Webhost - Redireciona tudo para o diretório root
# Use somente em caso de emergência
#
#<IfModule mod_rewrite.c>
# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule .? / [R=302,L]
#</IfModule>
Webhost - Carrega o arquivo MAINT-index.html caso não encontre o index.php ou index.html
# If index.php isn't found then load the file MAINT-index.html from the same directory instead.
# Try: https://codepen.io/j_holtslander/pen/KNgbMP
#
DirectoryIndex index.php index.html MAINT-index.html
Webhost - Utiliza o formato UTF-8 em todos os arquivos de text e listados abaixo
AddDefaultCharset UTF-8
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
Webhost - Realiza a correção de requisição para o arquivo robots.txt
# Source: https://perishablepress.com/htaccess-cleanup/
<IfModule mod_alias.c>
RedirectMatch 301 (?<!^)/robots.txt$ /robots.txt
</IfModule>
Webhost - Altera o endereço de email do administrador do Apache
SetEnv SERVER_ADMIN [email protected]
Webhost - Remove o FileEtag do servidor
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
Webhost - Remove X-Powered-By entre outros valores para evitar o sniffing
<IfModule mod_headers.c>
Header always unset X-Powered-By
Header always unset Server
Header always unset X-Pingback
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://dominio.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Feature-Policy "geolocation 'none'; microphone 'none'; camera 'none'"
Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>
Webhost - Habilita o deflate nos arquivos
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
Addtype font/truetype .ttf
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/opentype" \
"font/truetype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/text" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
<IfModule mod_mime.c>
AddEncoding gzip svgz
</IfModule>
</IfModule>
Webhost - Habilita o expires nos arquivos
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rdf+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"
ExpiresByType application/schema+json "access plus 0 seconds"
ExpiresByType application/vnd.geo+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/vnd.microsoft.icon "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
# HTML
ExpiresByType text/html "access plus 1 week"
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
# Manifest files
ExpiresByType application/manifest+json "access plus 1 week"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media files
ExpiresByType audio/ogg "access plus 6 months"
ExpiresByType image/bmp "access plus 6 months"
ExpiresByType image/gif "access plus 6 months"
ExpiresByType image/jpeg "access plus 6 months"
ExpiresByType image/jpg "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType image/svg+xml "access plus 6 months"
ExpiresByType image/webp "access plus 6 months"
ExpiresByType video/mp4 "access plus 6 months"
ExpiresByType video/ogg "access plus 6 months"
ExpiresByType video/webm "access plus 6 months"
# Web fonts
# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 6 months"
ExpiresByType font/eot "access plus 6 months"
# OpenType
ExpiresByType font/opentype "access plus 6 months"
# TrueType
ExpiresByType application/x-font-ttf "access plus 6 months"
# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 6 months"
ExpiresByType application/x-font-woff "access plus 6 months"
ExpiresByType font/woff "access plus 6 months"
# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 6 months"
# Other
ExpiresByType image/svg+xml "access plus 6 months"
ExpiresByType text/x-cross-domain-policy "access plus 1 week"
</IfModule>
Webhost - Habilita o Keep-Alive
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
Webhost - Remove a assinatura do servidor
# See:
# * https://techjourney.net/improve-apache-web-server-security-use-servertokens-and-serversignature-to-disable-header/
# * https://www.unixmen.com/how-to-disable-server-signature-using-htaccess-or-by-editing-apache/
#
ServerSignature Off
Webhost - Filtra os métodos de requisição
<IfModule mod_rewrite.c>
RewriteRule ^(TRACE|TRACK) - [F]
</IfModule>
Webhost - Filtra strings de requisição suspeitas
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} \.\.\/ [OR]
RewriteCond %{QUERY_STRING} \.(bash|git|hg|log|svn|swp|cvs) [NC,OR]
RewriteCond %{QUERY_STRING} etc/passwd [NC,OR]
RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
RewriteCond %{QUERY_STRING} ftp: [NC,OR]
#RewriteCond %{QUERY_STRING} https?: [NC,OR]
RewriteCond %{HTTP_HOST} !^www\.YOURDOMAIN\.com\.br$ [NC]
RewriteCond %{QUERY_STRING} (<|%3C)script(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
RewriteCond %{QUERY_STRING} base64_decode\( [NC,OR]
RewriteCond %{QUERY_STRING} %24&x [NC,OR]
RewriteCond %{QUERY_STRING} 127\.0 [NC,OR]
RewriteCond %{QUERY_STRING} (^|\W)(globals|encode|localhost|loopback)($|\W) [NC,OR]
RewriteCond %{QUERY_STRING} (^|\W)(concat|insert|union|declare)($|\W) [NC,OR]
RewriteCond %{QUERY_STRING} %[01][0-9A-F] [NC]
RewriteCond %{QUERY_STRING} !^loggedout=true
RewriteCond %{QUERY_STRING} !^action=jetpack-sso
RewriteCond %{QUERY_STRING} !^action=rp
RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_
RewriteCond %{HTTP_REFERER} !^http://maps\.googleapis\.com
RewriteRule ^.* - [F]
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} http\:\/\/www\.google\.com\/humans\.txt\? [NC,OR]
RewriteCond %{QUERY_STRING} (img|thumb|thumb_editor|thumbopen).php [NC,OR]
RewriteCond %{QUERY_STRING} fckeditor [NC]
RewriteCond %{QUERY_STRING} revslider [NC]
RewriteRule .* - [F,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} http\:\/\/www\.google\.com\/humans\.txt\? [NC]
RewriteRule .* - [F,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{QUERY_STRING} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author|wp\-postpass|wptouch_switch_toggle|wordpress_logged_in|woocommerce_cart_).*$
RewriteCond %{HTTPS} !on
RewriteCond %{DOCUMENT_ROOT}/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-sw_.html -f
RewriteRule ^(.*) "/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-sw_.html" [L]
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{QUERY_STRING} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author|wp\-postpass|wptouch_switch_toggle|wordpress_logged_in|woocommerce_cart_).*$
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-https-sw_.html -f
RewriteRule ^(.*) "/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-https-sw_.html" [L]
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{QUERY_STRING} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(wp-includes|wp-content|wp-admin|\.php).*$
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author|wp\-postpass|wptouch_switch_toggle|wordpress_logged_in|woocommerce_cart_).*$
RewriteCond %{HTTPS} !on
RewriteCond %{DOCUMENT_ROOT}/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index.xml -f
RewriteRule ^(.*) "/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index.xml" [L]
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{QUERY_STRING} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(s\=|submit\=|wp\-admin|wp\-content|wp\-includes|\.php|/cart/|/my\-account/|/checkout/|/addons/|add\-to\-cart\=).*$
RewriteCond %{REQUEST_URI} !^.*(wp-includes|wp-content|wp-admin|\.php).*$
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author|wp\-postpass|wptouch_switch_toggle|wordpress_logged_in|woocommerce_cart_).*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-https.xml -f
RewriteRule ^(.*) "/wp-content/pep-vn/cache/request-uri/data/%{SERVER_NAME}/$1/index-https.xml" [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Webhost - Bloqueia Bad-Bots
# Start HackRepair.com Blacklist
RewriteEngine on
# Start Abuse Agent Blocking
RewriteCond %{HTTP_USER_AGENT} "^Mozilla.*Indy" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla.*NEWT" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Maxthon$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SeaMonkey$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Acunetix" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^binlar" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^BlackWidow" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Bolt 0" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^BOT for JCE" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Bot mailto\:craftbot@yahoo\.com" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^casper" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^checkprivacy" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^ChinaClaw" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^clshttp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^cmsworldmap" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Custo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Default Browser 0" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^diavol" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^DIIbot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^DISCo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^dotbot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Download Demon" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^eCatch" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^EirGrabber" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^EmailCollector" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^EmailSiphon" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^EmailWolf" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Express WebPictures" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^extract" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^ExtractorPro" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^EyeNetIE" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^feedfinder" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^FHscan" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^FlashGet" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^flicky" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^g00g1e" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^GetRight" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^GetWeb\!" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Go\!Zilla" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Go\-Ahead\-Got\-It" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^grab" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^GrabNet" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Grafula" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^harvest" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^HMView" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Image Stripper" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Image Sucker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^InterGET" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Internet Ninja" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^InternetSeer\.com" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^jakarta" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Java" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^JetCar" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^JOC Web Spider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^kanagawa" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^kmccrew" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^larbin" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^LeechFTP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^libwww" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Mass Downloader" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^microsoft\.url" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^MIDown tool" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^miner" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Mister PiX" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^MSFrontPage" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Navroad" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^NearSite" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Net Vampire" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^NetAnts" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^NetSpider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^NetZIP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^nutch" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Octopus" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Offline Explorer" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Offline Navigator" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^PageGrabber" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Papa Foto" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^pavuk" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^pcBrowser" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^PeoplePal" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^planetwork" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^psbot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^purebot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^pycurl" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^RealDownload" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^ReGet" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Rippers 0" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^sitecheck\.internetseer\.com" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SiteSnagger" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^skygrid" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SmartDownload" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^sucker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SuperBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SuperHTTP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Surfbot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^tAkeOut" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Teleport Pro" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Toata dragostea mea pentru diavola" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^turnit" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^vikspider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^VoidEYE" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Web Image Collector" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebAuto" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebBandit" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebCopier" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebFetch" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebGo IS" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebLeacher" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebReaper" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebSauger" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Website eXtractor" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Website Quester" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebStripper" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebWhacker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WebZIP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Widow" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WPScan" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WWW\-Mechanize" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^WWWOFFLE" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Xaldon WebSpider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Zeus" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^zmeu" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "360Spider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "CazoodleBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "discobot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "EasouSpider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "ecxi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "GT\:\:WWW" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "heritrix" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "HTTP\:\:Lite" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "HTTrack" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "ia_archiver" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "id\-search" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "IDBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Indy Library" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "IRLbot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "ISC Systems iRc Search 2\.1" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "LinksCrawler" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "LinksManager\.com_bot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "linkwalker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "lwp\-trivial" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MFC_Tear_Sample" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Microsoft URL Control" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Missigua Locator" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MJ12bot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "panscient\.com" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "PECL\:\:HTTP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "PHPCrawl" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "PleaseCrawl" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SBIder" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SearchmetricsBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Snoopy" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Steeler" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "URI\:\:Fetch" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "urllib" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Web Sucker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "webalta" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WebCollage" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Wells Search II" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WEP Search" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "XoviBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "YisouSpider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "zermelo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "ZyBorg" [NC,OR]
# End Abuse Agent Blocking
# Start Abuse HTTP Referrer Blocking
RewriteCond %{HTTP_REFERER} "^https?://(?:[^/]+\.)?semalt\.com" [NC,OR]
RewriteCond %{HTTP_REFERER} "^https?://(?:[^/]+\.)?kambasoft\.com" [NC,OR]
RewriteCond %{HTTP_REFERER} "^https?://(?:[^/]+\.)?savetubevideo\.com" [NC]
# End Abuse HTTP Referrer Blocking
RewriteRule ^.* - [F,L]
# End HackRepair.com Blacklist, http://pastebin.com/u/hackrepair
Desabilita navegação de diretorios vazios
Options -Indexes -FollowSymLinks
Webhost - Protege o arquivo htaccess
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
Webhost - Adiciona suporte para os arquivos svg e htc
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
AddType text/x-component .htc
Webhost - Adiciona suporte para os arquivos reality
# See: https://webkit.org/blog/8421/viewing-augmented-reality-assets-in-safari-for-ios/
#
# All files ending in .usdz served as USD.
AddType model/vnd.usdz+zip usdz
Wordpress - Bloqueia acesso ao XMLRCP
<Files xmlrpc.php>
Require all denied
</Files>
Exclui os arquivos de ajax, upload e scripts do cron do Wordpress da autenticação
<FilesMatch "(admin-ajax\.php|media-upload\.php|async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Order allow,deny
Allow from all
Satisfy any
</FilesMatch>
Wordpress - Desabilita a inclusão de arquivos em diretorios sensiveis do WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Block direct access to sensitive directories
RewriteRule ^wp-admin/includes/ - [F,NC]
RewriteRule ^wp-includes/ - [F,NC]
# Block direct access to PHP files in wp-includes
RewriteRule ^wp-includes/.+\.php$ - [F,NC]
# Block direct access to language files in wp-includes/js/tinymce/langs
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,NC]
# Block direct access to theme-compat directory
RewriteRule ^wp-includes/theme-compat/ - [F,NC]
</IfModule>
Wordpress - Protege arquivos do sistema do WordPress
<IfModule mod_authz_core.c>
<FilesMatch "(^\.htaccess|readme\.(html|txt)|wp-config\.php)$">
Require all denied
</FilesMatch>
<FilesMatch "(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op]|sftp-config\.json)">
Require all denied
</FilesMatch>
</IfModule>
<IfModule !mod_authz_core.c>
<FilesMatch "(^\.htaccess|readme\.(html|txt)|wp-config\.php)$">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op]|sftp-config\.json)">
Order allow,deny
Deny from all
</FilesMatch>
</IfModule>
Webhost - Força o internet explorer 8/9/10 a renderizar páginas no modo mais alto
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
Webhost - Serve arquivos com o mimetype correto
<IfModule mod_mime.c>
# Data interchange
AddType application/atom+xml atom
AddType application/json json map topojson
AddType application/ld+json jsonld
AddType application/rss+xml rss
AddType application/vnd.geo+json geojson
AddType application/xml rdf xml
# JavaScript
AddType application/javascript js
# Manifest files
AddType application/manifest+json webmanifest
AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache
# Media files
AddType audio/mp4 f4a f4b m4a
AddType audio/ogg oga ogg opus
AddType image/bmp bmp
AddType image/svg+xml svg svgz
AddType image/webp webp
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
AddType video/webm webm
AddType video/x-flv flv
AddType image/x-icon cur ico
# Web fonts
AddType application/font-woff woff
AddType application/font-woff2 woff2
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Other
AddType application/octet-stream safariextz
AddType application/x-bb-appworld bbaw
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType text/vcard vcard vcf
AddType text/vnd.rim.location.xloc xloc
AddType text/vtt vtt
AddType text/x-component htc
</IfModule>
Webhost - Codificação de caracteres em formato UTF-8
AddDefaultCharset utf-8
<IfModule mod_mime.c>
AddCharset utf-8 .atom \
.bbaw \
.css \
.geojson \
.js \
.json \
.jsonld \
.manifest \
.rdf \
.rss \
.topojson \
.vtt \
.webapp \
.webmanifest \
.xloc \
.xml
</IfModule>
Webhost - Adiciona o encondig em arquivos para aumentar a perfomance
# VARY ENCODING - https://www.maxcdn.com/blog/accept-encoding-its-vary-important/
<IfModule mod_headers.c>
<FilesMatch ".(js|css|xml|gz|html|woff|woff2)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
Webhost - Habilita o GZIP em arquivos para aumentar a perfomance
<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>
WordPress - Protege o diretório wp-includes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
WordPress - Desabilita arquivos .php no diretorio de upload
<IfModule mod_rewrite.c>
RewriteRule ^wp-content/uploads/.*\.(?:php[1-7]?|pht|phtml?|phps)\.?$ - [F]
</IfModule>
WordPress - Desabilita arquivos .php no diretorio de plugins
<IfModule mod_rewrite.c>
RewriteRule ^wp-content/plugins/.*\.(?:php[1-7]?|pht|phtml?|phps)\.?$ - [F]
</IfModule>
WordPress - Desabilita arquivos .php no diretorio de temas
<IfModule mod_rewrite.c>
RewriteRule ^wp-content/themes/.*\.(?:php[1-7]?|pht|phtml?|phps)\.?$ - [F]
</IfModule>
WordPress - Desabilita a enumeração de usuários no WordPress
# See: https://www.wpbeginner.com/wp-tutorials/how-to-discourage-brute-force-by-blocking-author-scans-in-wordpress/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (author=\d+) [NC]
RewriteRule .* - [F]
</IfModule>
WordPress - Altera o caminho de url do login padrão para outro
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-login\.php$ - [R=404,L]
RewriteRule ^novo-login$ /wp-login.php [L]
</IfModule>
# END WordPress
WordPress - Evita postagens de comentários sem uma referência clara do navegador
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-login\.php$ - [R=404,L]
RewriteRule ^novo-login$ /wp-login.php [L]
</IfModule>
# END WordPress
Webhost - Desabilita o eastereggs do PHP (pode ser utilizado para determinar a versão do PHP)
# See http://www.0php.com/php_easter_egg.php and http://osvdb.org/12184 for more information
# Ref : http://journalxtra.com/websiteadvice/wordpress-security-hardening-htaccess-rules/
RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC]
RewriteRule .* - [F,L]
Webhost - Redireciona o feeds para o feedsburner
<IfModule mod_alias.c>
RedirectMatch 301 /feed/(atom|rdf|rss|rss2)/?$ http://feedburner.com/yourfeed/
RedirectMatch 301 /comments/feed/(atom|rdf|rss|rss2)/?$ http://feedburner.com/yourfeed/
</IfModule>
Mostra o titulo da página - Utilização: [page_title]
function show_page_title() {
$title = get_transient('show_page_title');
if (false === $title) {
$title = get_the_title();
set_transient('show_page_title', $title, 1 * HOUR_IN_SECONDS);
}
return esc_html($title) ?: 'Untitled';
}
add_shortcode('page_title', 'show_page_title');
Obtém a URL da página ou post - Utilização: [page_url]
function show_page_url() {
$url = get_transient('show_page_url');
if (false === $url) {
$url = get_permalink();
$url = rtrim($url, '/');
set_transient('show_page_url', $url, 1 * HOUR_IN_SECONDS);
}
return esc_url($url);
}
add_shortcode('page_url', 'show_page_url');
Exibe a imagem em destaque do post - Utilização: [thumb size="thumbnail"]
function show_thumb($atts) {
$atts = shortcode_atts(array(
'size' => 'thumbnail',
), $atts);
$thumbnail = get_the_post_thumbnail(null, $atts['size']);
$caption = get_the_post_thumbnail_caption();
$link = get_permalink();
return '<div class="featured-image">'
. $thumbnail . '<span class="caption imgPerfil">' . esc_html($caption) . '</span>'
. '</div>';
}
add_shortcode('thumb', 'show_thumb');
Exibe os últimos posts - Utilização: [latest_post]
function latest_post() {
$the_query = new WP_Query(array(
'category_name' => 'noticias',
'posts_per_page' => 3,
));
$output = ''; // initialize output variable
if ($the_query->have_posts()) {
$output .= '<div class="latest-posts">'; // start a container div
foreach ($the_query->posts as $post) {
setup_postdata($post);
$output .= '<div class="latest-post">';
$output .= '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, array(80, 80)) . '</a>';
$output .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
$output .= '</div>';
}
$output .= '</div>'; // close the container div
wp_reset_query();
} else {
$output .= '<p>' . __('No News') . '</p>';
}
return $output;
}
add_shortcode('latest_post', 'latest_post');
Exibe a data de última atualização do post - Utilização: [update_time]
function update_time() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
// Only display modified date if 24 hours have passed since the post was published.
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y');
$updated_time = get_the_modified_time('h:i a');
$description = empty($desc) ? '' : $desc . ' ';
$description .= $updated_date . ' ' . $updated_time;
return wp_kses_post($description);
}
}
add_shortcode('update_time', 'update_time');
Conta o número total de posts publicados de uma categoria especifica - Utilização: [cat_count]
function update_time() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
// Only display modified date if 24 hours have passed since the post was published.
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y');
$updated_time = get_the_modified_time('h:i a');
$description = empty($desc) ? '' : $desc . ' ';
$description .= $updated_date . ' ' . $updated_time;
return wp_kses_post($description);
}
}
add_shortcode('update_time', 'update_time');
Obtém e exibe a imagem diretamente do diretório do tema ativo - Utilização: [get_the image="/caminho/imagem.extensao"]
function update_time() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
// Only display modified date if 24 hours have passed since the post was published.
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y');
$updated_time = get_the_modified_time('h:i a');
$description = empty($desc) ? '' : $desc . ' ';
$description .= $updated_date . ' ' . $updated_time;
return wp_kses_post($description);
}
}
add_shortcode('update_time', 'update_time');
Obtém a URL do usuário atual logado - Utilização: [user_url]
function update_time() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
// Only display modified date if 24 hours have passed since the post was published.
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y');
$updated_time = get_the_modified_time('h:i a');
$description = empty($desc) ? '' : $desc . ' ';
$description .= $updated_date . ' ' . $updated_time;
return wp_kses_post($description);
}
}
add_shortcode('update_time', 'update_time');
Gera uma URL para um post aleatório - Utilização: [random_post]
function update_time() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
// Only display modified date if 24 hours have passed since the post was published.
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y');
$updated_time = get_the_modified_time('h:i a');
$description = empty($desc) ? '' : $desc . ' ';
$description .= $updated_date . ' ' . $updated_time;
return wp_kses_post($description);
}
}
add_shortcode('update_time', 'update_time');