的.htaccess或httpd.conf文件 [英] .htaccess or httpd.conf

查看:243
本文介绍了的.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.com/dir1/dir2/dir3/file请求

Say you have a request for www.example.com/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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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