抱歉,如果这是一个菜鸟问题,但我最近知道通过在 magento 中启用 gzip 可以提高应用程序速度。但是 magento 目录中的 .htaccess 文件似乎太多了。所以我必须在所有目录上启用还是只在 /var/www/html/magento/.htaccess
上启用? ?
/var/www/html/magento/.htaccess
/var/www/html/magento/.htaccess.sample
/var/www/html/magento/app/.htaccess
/var/www/html/magento/downloader/.htaccess
/var/www/html/magento/downloader/template/.htaccess
/var/www/html/magento/errors/.htaccess
/var/www/html/magento/includes/.htaccess
/var/www/html/magento/lib/.htaccess
/var/www/html/magento/media/.htaccess
/var/www/html/magento/media/customer/.htaccess
/var/www/html/magento/media/downloadable/.htaccess
/var/www/html/magento/pkginfo/.htaccess
/var/www/html/magento/var/.htaccess
最佳答案
.htaccess 设置自上而下流动。
除非您知道自己在做什么,否则不要弄乱 Magento 根目录下的子目录 .htaccess 文件,它们是用来保护 Magento 系统的。例如,弄乱 app/etc/.htaccess
可能会暴露您的加密 key 和数据库访问凭据,如果您启用了对 MySQL 的远程访问,这是一个特别致命的错误。你刚刚把你王国的 key 交给了外界。
要启用 deflate/gzip,首先您的 apache 服务器必须启用正确的模块 ( mod_deflate )。然后在 Magento 根文件夹中的 .htaccess 文件中查找设置并启用压缩。 Magento 为您预先安装了它,但注释掉了这些行。
要查看您的系统是否支持 deflate/gzip,请创建 <?php phpinfo(); ?>
文件,运行它并查找 mod_deflate 在 apache2handler 下加载。以下是一个示例
Loaded Modules core mod_log_config mod_logio prefork http_core mod_so mod_actions
mod_alias mod_auth_basic mod_authn_file mod_authz_default
mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex
mod_cgi mod_deflate mod_dir mod_env mod_expires mod_fastcgi
mod_headers mod_include mod_mime mod_negotiation mod_php5
mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status
mod_suexec
Magento 的预加载 .htaccess 部分需要一些修改才能启用 deflate/gzip
删除相应行前面的 # 以启用压缩,如下所示:
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
关于.htaccess - 通过在 .htaccess 中启用 gzip 来提高 magento 速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14744720/