HTML5 样板 .htaccess 与 httpd.conf
首先我想说我对使用 apache 很陌生,所以请不要反对我。
HTML5 Boilerplate 附带了一个 .htaccess 文件,但我使用的是 django(在 webfaction 上),所以我有一个用于 apache 的 httpd.conf 文件。我可以将 Boilerplates .htaccess 文件中的代码放入我的 httpd.conf 中吗?我对两者之间的区别感到困惑,希望您能提供任何帮助/见解?
I'd like to start off by saying I am really new to working with apache, so please don't hold it against me.
The HTML5 Boilerplate comes with a .htaccess file, but I'm using django (on webfaction) and so I have a httpd.conf file for apache. Can I put the code that's in the Boilerplates .htaccess file into my httpd.conf? I'm confused at the difference between the two and would appreciate any help / insight you can give?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
样板文件
.htaccess
中的大多数/所有规则都可以移至httpd.conf
,事实上,这会带来小小的性能提升,因为httpd .conf
文件只需要由 Apache 加载一次,而它需要在每次页面加载时读取.htaccess
。这当然也意味着对httpd.conf
的更改将需要重新启动守护进程(sudo apache2ctl -k Graceful
或类似的。)一般来说,您将相对“静态”的内容放在
httpd.conf
中,并将您可能想要轻松编辑且无需重新启动 Apache 守护进程的内容放在.htaccess
中。在共享主机上,客户通常只能使用.htaccess
来修改服务器行为,因此在这种情况下,这是您唯一的选择。Most/all of the rules in the boilerplate's
.htaccess
can be moved tohttpd.conf
, and in fact this will give a small performance boost, because thehttpd.conf
file only needs to be loaded once by Apache, whereas it needs to read the.htaccess
on every page load. This of course also means that changes tohttpd.conf
will need a daemon restart (sudo apache2ctl -k graceful
or similar.)In general, you put things that are relatively "static" in
httpd.conf
, and things that you might want to edit easily and without restarting the Apache daemon, in.htaccess
. On shared hosts, the customer can typically only use.htaccess
to modify the server behavior, so in that case that's the only choice you have.