简体   繁体   English

在 Apache 中使用 .htaccess 文件

[英]Using .htaccess file in Apache

There is any performance issue using .htaccess with the 'deny from all' instruction in all main directories in an web aplication?在 Web 应用程序的所有主目录中使用 .htaccess 和“拒绝所有”指令是否存在任何性能问题? Tks. Tks。

Using .htaccess files slows down Apache.使用.htaccess文件会降低 Apache 的速度。 If you can, modify the main server config file (usually called httpd.conf )如果可以,请修改主服务器配置文件(通常称为httpd.conf

From the manual:从手册:

You should avoid using .htaccess files completely if you have access to httpd main server config file.如果您有权访问 httpd 主服务器配置文件,则应完全避免使用 .htaccess 文件。 Using .htaccess files slows down your Apache http server.使用 .htaccess 文件会降低 Apache http 服务器的速度。 Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.您可以在 .htaccess 文件中包含的任何指令最好在 Directory 块中设置,因为它具有相同的效果和更好的性能。

http://httpd.apache.org/docs/current/howto/htaccess.html . http://httpd.apache.org/docs/current/howto/htaccess.html

On the other hand if you want to discuss or argue the performance loss versus the loss of ease of maintenance see this post bySimon Greenhill and his benchmarking results.另一方面,如果您想讨论或争论性能损失与维护简易性的损失,请参阅Simon Greenhill 的这篇文章和他的基准测试结果。

I found an article that explains why .htaccess may slow down your Apache server that's relevant to this question I think.我找到了一篇文章,解释了为什么.htaccess 可能会降低您的 Apache 服务器的速度,我认为这与我认为的这个问题有关。

From the article:从文章:

the .htaccess page may slow down your server somewhat; .htaccess 页面可能会稍微减慢您的服务器的速度; for most servers this will probably be an imperceptible change.对于大多数服务器来说,这可能是一种难以察觉的变化。 This is because of the location of the page: the .htaccess file affects the pages in its directory and all of the directories under it.这是因为页面的位置:.htaccess 文件影响其目录中的页面及其下的所有目录。 Each time a page loads, the server scans its directory, and any above it until it reaches the highest directory or an .htaccess file.每次加载页面时,服务器都会扫描它的目录以及它上面的任何目录,直到它到达最高目录或 .htaccess 文件。 This process will occur as long as the AllowOverride allows the use of .htaccess files, whether or not the file the .htaccess files actually exists.只要 AllowOverride 允许使用 .htaccess 文件,无论 .htaccess 文件是否实际存在,这个过程就会发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM