htaccess站点优化

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了htaccess站点优化相关的知识,希望对你有一定的参考价值。

  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]

以上是关于htaccess站点优化的主要内容,如果未能解决你的问题,请参考以下文章

Magento 站点切换.htaccess

.htaccess伪静态(URL重写)绑定域名到子目录实现子站点

.htaccess 保留页面而不更改站点 URL

使用 htaccess 重定向整个站点

修改两个站点的 htaccess 文件

.htaccess 规则在用户使用站点时使站点脱机