Last active
April 9, 2019 12:44
-
-
Save simbus82/0a1a863c58bc79af2ebd to your computer and use it in GitHub Desktop.
.htaccess to use in Joomla root
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
## | |
# @package Joomla | |
# @copyright Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved. | |
# @license GNU General Public License version 2 or later; see LICENSE.txt | |
## | |
## | |
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE! | |
# | |
# The line 'Options +FollowSymLinks' may cause problems with some server configurations. | |
# It is required for the use of mod_rewrite, but it may have already been set by your | |
# server administrator in a way that disallows changing it in this .htaccess file. | |
# If using it causes your site to produce an error, comment it out (add # to the | |
# beginning of the line), reload your site in your browser and test your sef urls. If | |
# they work, then it has been set by your server administrator and you do not need to | |
# set it here. | |
## | |
## No directory listings | |
<IfModule autoindex> | |
IndexIgnore * | |
</IfModule> | |
## Suppress mime type detection in browsers for unknown types | |
<IfModule mod_headers.c> | |
Header always set X-Content-Type-Options "nosniff" | |
</IfModule> | |
## Can be commented out if causes errors, see notes above. | |
Options +FollowSymlinks | |
Options -Indexes | |
## Mod_rewrite in use. | |
RewriteEngine On | |
## Begin - Rewrite rules to block out some common exploits. | |
# If you experience problems on your site then comment out the operations listed | |
# below by adding a # to the beginning of the line. | |
# This attempts to block the most common type of exploit `attempts` on Joomla! | |
# | |
# Block any script trying to base64_encode data within the URL. | |
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] | |
# Block any script that includes a <script> tag in URL. | |
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] | |
# Block any script trying to set a PHP GLOBALS variable via URL. | |
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] | |
# Block any script trying to modify a _REQUEST variable via URL. | |
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) | |
# Return 403 Forbidden header and show the content of the root home page | |
RewriteRule .* index.php [F] | |
# | |
## End - Rewrite rules to block out some common exploits. | |
## Begin - Custom redirects | |
# | |
# If you need to redirect some pages, or set a canonical non-www to | |
# www redirect (or vice versa), place that code here. Ensure those | |
# redirects use the correct RewriteRule syntax and the [R=301,L] flags. | |
### | |
# Redirect all "not correct" domain to www with https | |
# (is not important if comes with or without https): | |
# RewriteCond %{HTTP_HOST} !^www.mysite.it$ [NC] | |
# RewriteRule ^(.*)$ https://www.mysite.it/$1 [L,R=301] | |
# Redirect all non-ssl to ssl. | |
# RewriteCond %{HTTPS} off | |
# RewriteRule ^(.*)$ https://www.mysite.it/$1 [R=301,L] | |
### | |
## Inzio - Disabilita utenti K2 | |
RedirectMatch 404 ^.*/authors/.* | |
RedirectMatch 404 ^.*/author/.* | |
## Fine - Disabilita utenti K2 | |
# | |
## End - Custom redirects | |
## | |
# Uncomment the following line if your webserver's URL | |
# is not directly related to physical file paths. | |
# Update Your Joomla! Directory (just / for root). | |
## | |
# RewriteBase / | |
## Begin - Joomla! core SEF Section. | |
# | |
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
# | |
# If the requested path and file is not /index.php and the request | |
# has not already been internally rewritten to the index.php script | |
RewriteCond %{REQUEST_URI} !^/index\.php | |
# and the requested path and file doesn't directly match a physical file | |
RewriteCond %{REQUEST_FILENAME} !-f | |
# and the requested path and file doesn't directly match a physical folder | |
RewriteCond %{REQUEST_FILENAME} !-d | |
# internally rewrite the request to the index.php script | |
RewriteRule .* index.php [L] | |
# | |
## End - Joomla! core SEF Section. | |
## Inizio - Ottimizzazione delle prestazioni del sito, cache e compressione dei file. | |
# Ottimizzazione delle prestazioni del sito, cache e compressione dei file. | |
# This rule will create an ETag for files based only on the modification | |
# timestamp and their size. | |
# Note: It may cause problems on your server and you may need to remove it | |
FileETag MTime Size | |
# Enable expiration control | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
# Default expiration: 1 hour after request | |
ExpiresDefault "now plus 1 hour" | |
# Your document html | |
ExpiresByType text/html "access plus 0 seconds" | |
# Data | |
ExpiresByType text/xml "access plus 0 seconds" | |
ExpiresByType application/xml "access plus 0 seconds" | |
ExpiresByType application/json "access plus 0 seconds" | |
# Feed | |
ExpiresByType application/rss+xml "access plus 1 hour" | |
ExpiresByType application/atom+xml "access plus 1 hour" | |
# Favicon (cannot be renamed) | |
ExpiresByType image/x-icon "access plus 1 week" | |
# HTC files (css3pie) | |
ExpiresByType text/x-component "access plus 1 month" | |
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) | |
ExpiresByType text/cache-manifest "access plus 0 seconds" | |
# CSS and JS expiration: 1 week after request | |
ExpiresByType text/css "now plus 1 week" | |
ExpiresByType application/javascript "now plus 1 week" | |
ExpiresByType application/x-javascript "now plus 1 week" | |
# Image files expiration: 1 month after request | |
ExpiresByType image/bmp "now plus 1 month" | |
ExpiresByType image/gif "now plus 1 month" | |
ExpiresByType image/jpeg "now plus 1 month" | |
ExpiresByType image/jp2 "now plus 1 month" | |
ExpiresByType image/pipeg "now plus 1 month" | |
ExpiresByType image/png "now plus 1 month" | |
ExpiresByType image/svg+xml "now plus 1 month" | |
ExpiresByType image/tiff "now plus 1 month" | |
ExpiresByType image/vnd.microsoft.icon "now plus 1 month" | |
ExpiresByType image/x-icon "now plus 1 month" | |
ExpiresByType image/ico "now plus 1 month" | |
ExpiresByType image/icon "now plus 1 month" | |
ExpiresByType text/ico "now plus 1 month" | |
ExpiresByType application/ico "now plus 1 month" | |
ExpiresByType image/vnd.wap.wbmp "now plus 1 month" | |
ExpiresByType application/vnd.wap.wbxml "now plus 1 month" | |
ExpiresByType application/smil "now plus 1 month" | |
# Audio files expiration: 1 month after request | |
ExpiresByType audio/basic "now plus 1 month" | |
ExpiresByType audio/mid "now plus 1 month" | |
ExpiresByType audio/midi "now plus 1 month" | |
ExpiresByType audio/mpeg "now plus 1 month" | |
ExpiresByType audio/x-aiff "now plus 1 month" | |
ExpiresByType audio/x-mpegurl "now plus 1 month" | |
ExpiresByType audio/x-pn-realaudio "now plus 1 month" | |
ExpiresByType audio/x-wav "now plus 1 month" | |
# Movie files expiration: 1 month after request | |
ExpiresByType application/x-shockwave-flash "now plus 1 month" | |
ExpiresByType x-world/x-vrml "now plus 1 month" | |
ExpiresByType video/x-msvideo "now plus 1 month" | |
ExpiresByType video/mpeg "now plus 1 month" | |
ExpiresByType video/mp4 "now plus 1 month" | |
ExpiresByType video/quicktime "now plus 1 month" | |
ExpiresByType video/x-la-asf "now plus 1 month" | |
ExpiresByType video/x-ms-asf "now plus 1 month" | |
# Webfonts | |
ExpiresByType application/font-ttf "access plus 1 month" | |
ExpiresByType font/opentype "access plus 1 month" | |
ExpiresByType application/font-woff "access plus 1 month" | |
ExpiresByType application/font-woff2 "access plus 1 month" | |
ExpiresByType image/svg+xml "access plus 1 month" | |
ExpiresByType application/vnd.ms-fontobject "access plus 1 month" | |
<IfModule mod_headers.c> | |
Header append Cache-Control "public" | |
</IfModule> | |
</IfModule> | |
# Compress HTML, CSS, JavaScript, Text, XML and fonts | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject | |
AddOutputFilterByType DEFLATE application/x-font | |
AddOutputFilterByType DEFLATE application/x-font-opentype | |
AddOutputFilterByType DEFLATE application/x-font-otf | |
AddOutputFilterByType DEFLATE application/x-font-truetype | |
AddOutputFilterByType DEFLATE application/x-font-ttf | |
AddOutputFilterByType DEFLATE application/x-javascript | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE application/x-font-woff | |
AddOutputFilterByType DEFLATE font/ttf | |
AddOutputFilterByType DEFLATE font/otf | |
AddOutputFilterByType DEFLATE font/opentype | |
AddOutputFilterByType DEFLATE font/woff | |
AddOutputFilterByType DEFLATE font/woff2 | |
AddOutputFilterByType DEFLATE image/svg+xml | |
AddOutputFilterByType DEFLATE image/x-icon | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/xml | |
# Remove browser bugs (only needed for really old browsers) | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
Header append Vary User-Agent | |
</IfModule> | |
## Fine - Ottimizzazione delle prestazioni del sito, cache e compressione dei file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment