Created
November 4, 2017 20:53
-
-
Save ahmed-bhs/a247b0837a7e2a29a4de4d05131ccb16 to your computer and use it in GitHub Desktop.
Symfony'url rewriting, la gestion du cache, la compression et la sécurité
This file contains hidden or 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
# fichier .htaccess qui se trouvera à la racine de mon site web hébergé chez OVH | |
######## URL rewriting ######### | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ web/$1 [QSA,L] | |
</IfModule> | |
####### Params OVH ######### | |
SetEnv SHORT_OPEN_TAGS 0 | |
SetEnv REGISTER_GLOBALS 0 | |
SetEnv MAGIC_QUOTES 0 | |
SetEnv SESSION_AUTOSTART 0 | |
SetEnv ZEND_OPTIMIZER 1 | |
SetEnv PHP_VER 5_3 | |
####### Compressions ######## | |
# MOD_DEFLATE COMPRESSION | |
SetOutputFilter DEFLATE | |
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php | |
#Pour les navigateurs incompatibles | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html | |
#ne pas compresser si ces fichiers le sont déjà | |
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary | |
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary | |
SetEnvIfNoCase Request_URI \.(?:pdf|avi|mov|mp3|mp4|rm)$ no-gzip dont-vary | |
#les proxies doivent donner le bon contenu | |
Header append Vary User-Agent env=!dont-vary | |
########## Cache ######### | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpg "access plus 2592000 seconds" | |
ExpiresByType image/jpeg "access plus 2592000 seconds" | |
ExpiresByType image/png "access plus 2592000 seconds" | |
ExpiresByType image/gif "access plus 2592000 seconds" | |
AddType image/x-icon .ico | |
ExpiresByType image/ico "access plus 2592000 seconds" | |
ExpiresByType image/icon "access plus 2592000 seconds" | |
ExpiresByType image/x-icon "access plus 2592000 seconds" | |
ExpiresByType text/css "access plus 2592000 seconds" | |
ExpiresByType text/javascript "access plus 2592000 seconds" | |
ExpiresByType application/javascript "access plus 2592000 seconds" | |
ExpiresByType application/x-javascript "access plus 2592000 seconds" | |
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" | |
</IfModule> | |
# Enlever les Etags | |
Header unset ETag | |
FileETag none | |
########## Securité ####### | |
# Protection des fichier .htaccess | |
<files .htaccess> | |
order allow,deny | |
deny from all | |
</files> | |
# Protection de la lecture des répertoires | |
Options -Indexes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment