这个 .htaccess 是否存在确实会减慢页面请求速度的问题?
自从将这个基本的 .htaccess 添加到我的索引目录后,每个页面加载速度可能会减慢 20-30 秒:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)-(.+) movie.php?id=$1 [NC]
这里是否存在一些格式错误或错误的正则表达式格式?我看不出有什么问题。
谢谢!
作为更新,仅这两行就足以减慢速度:
Options +FollowSymlinks
RewriteEngine on
Since adding this basic .htaccess to my index directory, each page load slows down by maybe 20-30 seconds:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)-(.+) movie.php?id=$1 [NC]
Is there some malformation or bad regex formatting here? I can't see anything wrong with it.
Thanks!
As an update, just these 2 lines are enough to put the slow down on:
Options +FollowSymlinks
RewriteEngine on
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您正在通过电影脚本运行请求。那么 movie.php 脚本需要多长时间才能运行?如果需要 20-30 秒,那么就可以了!
It looks like you're running requests through your movie script. So how long does it take your movie.php script to run? If it takes 20-30 seconds, well, then there you go!
尽管我认为 20-30 秒有点牵强,但这里对您当前的正则表达式有一些担忧:
(.+)
确实如此)。因此,您可以将正则表达式简化为^(.+)-
。(.+)
相匹配。这不是最佳方法。最好使用([^-]+)
代替。这将处理任何不是-
的字符(这就是您想要的。)因此生成的规则是:
更好(这仅允许整数 ID):
Even though I think that 20-30 seconds is a little bit far-fetched, here some concerns about your current regex:
(.+)
does). Thus you may reduce the regex to^(.+)-
.(.+)
. That isn't the optimal approach. Better use([^-]+)
instead. This will mach any char that isn't an-
(and that's what you want.)The resulting Rule thus is:
Even better (this allows only integral IDs):
打开重写日志记录并提高级别,看看您的 RewriteRule 正在做什么:
如果正则表达式必须超时工作,您很快就会看到 Apache 的错误日志大小呈爆炸式增长,尤其是在更高级别的重写日志记录中。
Turn on rewrite logging and crank the level up, see what your RewriteRule is doing:
If the regex is having to work overtime, you'll quickly see Apache's error log explode in size, especially at the higher levels of rewrite logging.