使用 Mod-Rewrite 有什么负面影响吗? [英] Any negative impacts when using Mod-Rewrite?

查看:29
本文介绍了使用 Mod-Rewrite 有什么负面影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 mod-rewrite 完成了很多积极的事情.但有负面影响吗?显然,如果你的规则写得不好,你就会遇到问题.但是,如果您有一个高容量站点并且您经常使用 mod-rewrite,它会不会对性能产生重大影响呢?我在谷歌上快速搜索了一些基准,但没有找到太多.

I know there are a lot of positive things mod-rewrite accomplishes. But are there any negative? Obviously if you have poorly written rules your going to have problems. But what if you have a high volume site and your constantly using mod-rewrite, is it going to have a significant impact on performance? I did a quick search for some benchmarks on Google and didn't find much.

推荐答案

我在网站上使用了 mod_rewrite,这些网站每月点击数百万次,没有任何重大的性能问题.您必须知道根据您的规则首先应用哪些重写.

I've used mod_rewrite on sites that get millions/hits/month without any significant performance issues. You do have to know which rewrites get applied first depending on your rules.

使用 mod_rewrite 很可能比用您当前的语言解析 URL 更快.

Using mod_rewrite is most likely faster than parsing the URL with your current language.

如果您真的很担心性能,请不要使用 .htaccess 文件,这些文件很慢.将所有重写规则放在 Apache 配置中,该配置仅在启动时读取一次..htaccess 文件会在每次请求时重新解析,以及父文件夹中的 every .htaccess 文件.

If you are really worried about performance, don't use .htaccess files, those are slow. Put all your rewrite rules in your Apache config, which is only read once on startup. .htaccess files get re-parsed on every request, along with every .htaccess file in parent folders.

这篇关于使用 Mod-Rewrite 有什么负面影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆