Last active
November 28, 2019 17:29
-
-
Save mthchz/27fa428dc12524c237cee10be981515f to your computer and use it in GitHub Desktop.
htaccess optimisé pour Wordpress
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
Options -Indexes | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# WordPress | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
# To redirect all users WITH the 'www.' prefix | |
#RewriteCond %{HTTP_HOST} !^www\. [NC] | |
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
# To redirect all users WITHOUT the 'www.' prefix | |
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
# Redirect to https | |
#RewriteCond %{HTTPS} !=on | |
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
# add svg support | |
AddType image/svg+xml svg svgz | |
AddEncoding gzip svgz | |
# BEGIN Expire headers | |
<IfModule mod_expires.c> | |
ExpiresActive on | |
ExpiresDefault "access plus 1 month" | |
# DATA | |
ExpiresByType text/xml "access plus 0 seconds" | |
ExpiresByType text/html "access plus 0 seconds" | |
ExpiresByType text/plain "access plus 0 seconds" | |
ExpiresByType application/xml "access plus 0 seconds" | |
ExpiresByType application/json "access plus 0 seconds" | |
ExpiresByType application/rss+xml "access plus 1 hour" | |
ExpiresByType application/atom+xml "access plus 1 hour" | |
ExpiresByType text/x-component "access plus 1 hour" | |
# MANIFEST | |
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" | |
ExpiresByType text/cache-manifest "access plus 0 seconds" | |
# SCRIPTS | |
ExpiresByType text/css "access plus 1 month" | |
ExpiresByType text/javascript "access plus 1 month" | |
ExpiresByType application/javascript "access plus 1 month" | |
ExpiresByType application/x-javascript "access plus 1 month" | |
# IMAGES | |
ExpiresByType image/gif "access plus 1 month" | |
ExpiresByType image/png "access plus 1 month" | |
ExpiresByType image/jpe "access plus 1 month" | |
ExpiresByType image/jpg "access plus 1 month" | |
ExpiresByType image/jpeg "access plus 1 month" | |
ExpiresByType image/jp2 "access plus 1 month" | |
ExpiresByType image/pipeg "access plus 1 month" | |
ExpiresByType image/bmp "access plus 1 month" | |
ExpiresByType image/tiff "access plus 1 month" | |
ExpiresByType image/svg+xml "access plus 1 month" | |
ExpiresByType image/vnd.microsoft.icon "access plus 1 month" | |
# ICONS | |
ExpiresByType image/ico "access plus 1 month" | |
ExpiresByType image/icon "access plus 1 month" | |
ExpiresByType text/ico "access plus 1 month" | |
ExpiresByType image/x-ico "access plus 1 month" | |
ExpiresByType image/x-icon "access plus 1 month" | |
ExpiresByType application/ico "access plus 1 month" | |
# AUDIO | |
ExpiresByType audio/ogg "access plus 1 month" | |
ExpiresByType audio/basic "access plus 1 month" | |
ExpiresByType audio/mid "access plus 1 month" | |
ExpiresByType audio/midi "access plus 1 month" | |
ExpiresByType audio/mpeg "access plus 1 month" | |
ExpiresByType audio/x-aiff "access plus 1 month" | |
ExpiresByType audio/x-mpegurl "access plus 1 month" | |
ExpiresByType audio/x-pn-realaudio "access plus 1 month" | |
ExpiresByType audio/x-wav "access plus 1 month" | |
# VIDEO | |
ExpiresByType video/ogg "access plus 1 month" | |
ExpiresByType video/mp4 "access plus 1 month" | |
ExpiresByType video/webm "access plus 1 month" | |
ExpiresByType video/x-msvideo "access plus 1 month" | |
ExpiresByType video/mpeg "access plus 1 month" | |
ExpiresByType video/quicktime "access plus 1 month" | |
ExpiresByType video/x-la-asf "access plus 1 month" | |
ExpiresByType video/x-ms-asf "access plus 1 month" | |
ExpiresByType x-world/x-vrml "access plus 1 month" | |
# FONTS | |
ExpiresByType font/truetype "access plus 1 month" | |
ExpiresByType font/opentype "access plus 1 month" | |
ExpiresByType application/x-font-ttf "access plus 1 month" | |
ExpiresByType application/x-font-woff "access plus 1 month" | |
ExpiresByType application/font-woff "access plus 1 month" | |
ExpiresByType application/vnd.ms-fontobject "access plus 1 month" | |
# FLASH | |
ExpiresByType application/x-shockwave-flash "access plus 1 month" | |
ExpiresByType video/x-flv "access plus 1 month" | |
# OTHERS | |
ExpiresByType application/pdf "access plus 1 month" | |
ExpiresByType image/vnd.wap.wbmp "access plus 1 month" | |
ExpiresByType application/vnd.wap.wbxml "access plus 1 month" | |
ExpiresByType application/smil "access plus 1 month" | |
<IfModule mod_headers.c> | |
Header append Cache-Control "public" | |
</IfModule> | |
</IfModule> | |
# END Expire headers | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext text/plain image/x-icon | |
<IfModule mod_headers.c> | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> | |
<IfModule mod_mime.c> | |
# DEFLATE by extension | |
AddOutputFilter DEFLATE js css htm html xml svg svgz | |
</IfModule> | |
</IfModule> | |
<IfModule mod_headers.c> | |
<FilesMatch ".(js|css|xml|gz|html)$"> | |
Header append Vary: Accept-Encoding | |
</FilesMatch> | |
</IfModule> | |
# BEGIN Cache-Control Headers : 2629800s > 1 month | |
<IfModule mod_headers.c> | |
<FilesMatch "\\.(js|css|jpg|png|jpeg|gif|css)$"> | |
Header set Cache-Control "max-age=2629800, public" | |
# Unset cookies for static content | |
RequestHeader unset Cookie | |
Header unset Set-Cookie | |
Header set Cache-Control "max-age=2629800" | |
</FilesMatch> | |
<FilesMatch "\.(js)$"> | |
Header set Cache-Control "max-age=2629800, private" | |
</FilesMatch> | |
<filesMatch "\.(html|htm)$"> | |
Header set Cache-Control "max-age=2629800, public" | |
</filesMatch> | |
# Disable caching for scripts and other dynamic files | |
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"> | |
Header unset Cache-Control | |
</FilesMatch> | |
</IfModule> | |
# END Cache-Control Headers | |
# BEGIN Security | |
# /!\ USE WITH CARE /!\ Not easy to configure | |
#<IfModule mod_headers.c> | |
# CSP (https://www.html5rocks.com/en/tutorials/security/content-security-policy/) | |
#Header set Content-Security-Policy "script-src 'self' //www.google-analytics.com; script-src 'self' https://opt-out.ferank.eu;style-src 'self' https://opt-out.ferank.eu" | |
# Block clickjacking | |
#Header always set X-FRAME-OPTIONS "DENY" | |
# Block XSS | |
#Header always set X-XSS-Protection "1; mode=block" | |
# Disable MIME Sniffing | |
#Header always set X-Content-Type-Options "nosniff" | |
#</IfModule> | |
# END Security |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment