dongyun8138 2012-10-02 11:25
浏览 61
已采纳

从目录移出到.htaccess文件会增加CPU加载时间和CPU周期

I have many hyperlinks like this: This link is placed in interact folder and links to the main folder.

<a href='../user/" . $id . "/".$name."' target='_self'>" . $name. "</a>

Which goes back to the main directory of the website and in the main directory there is a .htaccess file with this code

RewriteRule ^user/([0-9]*) interact/profile1.php?id=$1 [L,QSA]

I have done this to make URL look like:

http://www.domain.com/user/ 

Instead of this:

http://www.domain.com/interact/user

This makes the request return to the same directory it came from that is the /interact directory. I have many hyperlinks that do something like this. Will having many such hyperlinks increase the CPU load time ?

  • 写回答

1条回答 默认 最新

  • dsgdf45654 2012-10-03 16:54
    关注

    Yes, using rewriting uses more CPU. But it does not depend on the number of links, it depends on the number of requests done.

    And additionally, using a .htaccess file also impacts performance. A lot more than rewriting.

    Rewriting inside .htaccess has a double impact, because evaluating the .htaccess file takes place relatively late in the process, and a rewrite there basically starts the whole process all over.

    On the other hand the impact is measurable, but rarely noticeable on the average server. Are you in a high traffic situation? Then I'd suggest getting rid of the .htaccess files altogether, disabling them in the Apache configuration, and putting the rewriting rule into the vhost configuration.

    Residing there, they only have to be parsed when the server starts, and you avoid that the server constantly has to look for a .htaccess file in any directory that might be touched by a request.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建