Apache .htaccess 与 httpd - 这真的很重要吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/969998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache .htaccess vs httpd - does it really matter?
提问by frio80
I know this question has been asked many times and I've researched it myself on Google as well but just can't come up with the answer I need.
我知道这个问题已经被问过很多次了,我自己也在谷歌上研究过,但就是想不出我需要的答案。
My hosting company is NOT letting me use the httpd config file, instead it wants me to use .htaccess. I am not a server admin but I have to believe that there is a performance hit for using this file? I have a site with approx 5 million page views a month and it's growing. I do not have a lot of rewrite rules just some optimizations we make to serving pages faster ,mod_deflate, caching, etc.
我的托管公司不允许我使用 httpd 配置文件,而是希望我使用 .htaccess。我不是服务器管理员,但我必须相信使用此文件会影响性能?我有一个网站,每个月的页面浏览量约为 500 万次,而且还在增长。我没有很多重写规则,只是我们为更快地提供页面、mod_deflate、缓存等所做的一些优化。
Assuming there is a performance hit, my question is, how bad will it be on my site? Can .htaccess handle 5 million page views with some rewrite rules? How would I be able to test this if I wanted to?
假设性能受到影响,我的问题是,它在我的网站上会有多糟糕?.htaccess 可以通过一些重写规则处理 500 万次页面访问吗?如果我愿意,我将如何进行测试?
Thanks.
谢谢。
采纳答案by mikl
Well, to my knowledge, the performance difference is negilible, comparred to the computing time used for whatever's used in the .htaccess. For what's it's worth, I've seen no measurable difference by having a .htaccessfile.
好吧,据我所知,与 .htaccess 中使用的计算时间相比,性能差异可以忽略不计。对于它的价值,我没有看到拥有.htaccess文件有什么可衡量的差异。
回答by Nasser Al-Wohaibi
Yes, it does matter. qouting from http://wiki.apache.org/httpd/Htaccess:
是的,这很重要。来自http://wiki.apache.org/httpd/Htaccess 的qouting :
The use of .htaccess files is discouraged as they can have a detrimentaleffect on server performance. Only use them when necessary.
不鼓励使用 .htaccess 文件,因为它们会对服务器性能产生 不利影响。仅在必要时使用它们。
回答by Eduardo Cuomo
With my test (based on: http://www.fubra.com/blog/2008/01/07/htaccess-vs-httpdconf/), the result is: the performance difference is negligible.
通过我的测试(基于:http: //www.fubra.com/blog/2008/01/07/htaccess-vs-httpdconf/),结果是:性能差异可以忽略不计。
5000 rounds:
5000 轮:
# htaccess Disabled
real 1m1.069s
user 0m10.956s
sys 0m9.748s
# htaccess Enabled
real 1m1.658s
user 0m11.434s
sys 0m9.848s
回答by cletus
Performance hit for reading the file? That's micro-optimization. Favour .htaccess. You don't need special privileges to edit it.
读取文件的性能受到影响?这就是微观优化。支持 .htaccess。您不需要特殊权限来编辑它。
Also on a shared hosting site, everyone shares the httpd.conf settings so, if thats your situation, it's not applicable.
同样在共享托管站点上,每个人都共享 httpd.conf 设置,因此,如果这是您的情况,则它不适用。

