mod_rewrite 还是 mod_alias?
我有一个服务器,它的 httpd.conf 中已经有一些“RedirectMatch permanent”指令。
我对 mod_alias 不太熟悉,我只使用过 mod_rewrite 。
基本的区别是什么? 我在 mod_alias 中没有看到用于停止处理规则的“L”标志。
我应该使用哪一个来实现从一个子域重定向到另一个子域的最佳实践?
我可以同时使用两者吗?哪个优先会很明显吗?
I have a server, its httpd.conf already has some "RedirectMatch permanent" directives in it.
I'm not that familiar with mod_alias, I've only ever used mod_rewrite.
What's the basic difference? I don't see a "L" flag in mod_alias to stop processing rules.
Which one should I use for best practices of redirecting from one sub-domain to another?
Can I use both at the same time and will it be obvious which takes precedence?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
mod_alias 基本上是 mod_rewrite 的简单版本。 它无法执行 mod_rewrite 可以执行的某些操作,例如操作查询字符串。 如果您能够选择其中任何一个,我看不出您有任何理由要使用 mod_alias。
您需要尝试同时使用两者有什么具体原因吗?
Apache mod_rewrite & mod_alias 技巧你应该知道 似乎是一篇关于两者的好文章。 它注意到 mod_rewrite 规则在 mod_alias 规则之前执行。
mod_alias is basically a simpler version of mod_rewrite. It can't do some things that mod_rewrite can, such as manipulate the query string. If you're able to choose either of them, I don't see any reason that you'd want to use mod_alias.
Is there a specific reason you need to try to use both together?
Apache mod_rewrite & mod_alias tricks you should know seems to be a good article about the two. It notes at one point that mod_rewrite rules get executed before mod_alias ones.
正如接受的答案所说:
mod_rewrite
可以做mod_alias
不能做的事情。 然而,mod_alias
的主要好处是它更易于使用。apache 文档说我们应该使用
mod_alias
来处理重定向等简单的事情,而mod_rewrite
仅用于我们无法使用mod_alias
等简单模块完成的事情。 查看文档:何时不使用 mod_rewrite。As the accepted answer says:
mod_rewrite
can do things whichmod_alias
can't. However the main benefit ofmod_alias
is that it is easier to use.The apache docs say that we should use
mod_alias
for simple things like redirects andmod_rewrite
only for things we cannot do with simpler modules likemod_alias
. View the docs: When not to use mod_rewrite.