的.htaccess或httpd.conf文件

编程入门 行业动态 更新时间:2024-10-27 04:38:38
本文介绍了的.htaccess或httpd.conf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我现在要做一个URL重写工作。

I need to do a url-rewriting job now.

我不知道我是否应该把code成的.htaccess或httpd.conf文件?

I don't know whether I should put the code into a .htaccess or httpd.conf?

修改

什么的.htaccess的范围内 - 影响?它会影响到所有的请求,或只要求它位于特定的目录?

What's the effecting range of .htaccess?Will it affect all requests or only requests to the specific directory it's located?

推荐答案

如果你不会有改变你的规则,很多时候,你应该把它们在httpd.conf并关闭压倒一切的顶级目录的规则适用于

If you wont have to change your rules very often, you should put them in the httpd.conf and turn off overriding in the top directory your rules apply to

AllowOverride None

由于没有压​​倒一切的,你的apache不会扫描每个目录制作更小的开销为每个请求.htaccess文件。

With no overriding, your apache will not scan every directory for .htaccess files making less of an overhead for each request.

每当你必须改变你的规则,你将拥有,如果你把它放在你的httpd.conf,而不是他们在.htaccess文件被立即发现,因为它读取它们在每次请求重新启动Apache服务器。

Whenever you do have to change your rules, you will have to restart your apache server if you put it in your httpd.conf as opposed to them being instantly detected in .htaccess files because it reads them all on every request.

您可以使用优雅重启与apachectl中的工具,以避免切断被送达任何当前的请求很容易地做到这一点。

You can easily do this using a graceful restart with the apachectl tool to avoid cutting off any current requests being served.

apachectl graceful

如果你不打算把覆盖掉,你可能也只是使用的.htaccess而已。

If you aren't going to turn override off, you might as well just use .htaccess only.

编辑回应您的编辑:

假设你有www.example/dir1/dir2/dir3/file请求

Say you have a request for www.example/dir1/dir2/dir3/file

Apache将寻找在所有3这些目录的.htaccess文件和根的规则适用于请求,如果您还有压倒性的允许的。

Apache will look for a .htaccess file in all 3 of those directories and the root for rules to apply to the request if you have overriding allowed.

更多推荐

的.htaccess或httpd.conf文件

本文发布于:2023-07-16 04:01:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117636.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   htaccess   httpd   conf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!