htaccess site optimizing


/ Published in: Apache
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ### Translation proposed by Google
  2. Options +FollowSymlinks
  3. RewriteEngine on
  4. RewriteRule ^(.*)/en$ http://translate.google.com/translate?hl=en&sl=fr&tl=en&u=http://votresite.net/$1 [R,NC]
  5. RewriteRule ^(.*)/de$ http://translate.google.com/translate?hl=de&sl=fr&tl=de&u=http://votresite.net/$1 [R,NC]
  6.  
  7. ### Download without window dialog
  8. AddType application/octet-stream .pdf
  9. AddType application/octet-stream .zip
  10. AddType application/octet-stream .mov
  11.  
  12. ### Compress files
  13. AddOutputFilterByType DEFLATE text/plain
  14. AddOutputFilterByType DEFLATE text/html
  15. AddOutputFilterByType DEFLATE text/xml
  16. AddOutputFilterByType DEFLATE text/css
  17. AddOutputFilterByType DEFLATE application/javascript
  18. AddOutputFilterByType DEFLATE application/x-javascript
  19. AddOutputFilterByType DEFLATE application/xml
  20. AddOutputFilterByType DEFLATE application/xhtml+xml
  21. AddOutputFilterByType DEFLATE application/rss+xml
  22.  
  23. <IfModule mod_gzip.c>
  24. mod_gzip_on Yes
  25. mod_gzip_dechunk Yes
  26. mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  27. mod_gzip_item_include handler ^cgi-script$
  28. mod_gzip_item_include mime ^text/.*
  29. mod_gzip_item_include mime ^application/x-javascript.*
  30. mod_gzip_item_exclude mime ^image/.*
  31. mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
  32. </IfModule>
  33.  
  34. ### Put files in cache
  35. <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
  36. Header set Cache-Control "max-age=2592000"
  37. </FilesMatch>
  38.  
  39. ### Protect pictures from HOTLINKING
  40. RewriteEngine on
  41. RewriteCond %{HTTP_REFERER} !^http://(www.)?domain.net/.*$ [NC]
  42. RewriteCond %{HTTP_REFERER} ^http://(www.)?site-voleur-qui-hotlink.com/.*$ [NC]
  43. RewriteCond %{REQUEST_FILENAME} !/images/divers/grille.jpg$ [NC]
  44. RewriteRule .(gif|jpg|jpeg|png)$ /images/divers/grille.jpg [R,L]

URL: http://www.lafermeduweb.net/billet/-htaccess-quelques-astuces-bien-pratiques-a-connaitre-981.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.